0

I know that definition of URL says:

Most people realize that a space is not allowed in a URL. However, it is also important to realize, as documented in RFC 1738, the URL string can only contain alphanumeric characters and the !$-_+*'(), characters. Any other characters that are needed in the URL must be encoded.

But just to be sure, that will means that only 1 "?" character it´s allowed in the query, so my code it´s safe right?

 protected String addClientId(String uri) {
    return uri.contains("?") ? uri.concat("&clientId=" + clientId) : uri.concat("?clientId=" + clientId);
  }

I just want to be sure that even encoding the ? cannot appear in the url.

Regards.

paul
  • 12,873
  • 23
  • 91
  • 153
  • 1
    Not an answer to your question, but I'd recommend using a URL manipulation library of some sort, such as the one included in OkHttp. – Jonas Czech Mar 29 '16 at 13:47
  • 1
    Please consult [RFC3986](http://tools.ietf.org/html/rfc3986). 1738 has been obsoleted for quite a while. – DaSourcerer Mar 29 '16 at 13:50

0 Answers0