Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: update base64 url encoding example

...

Code Block
bgColor#FFCCCC
String buildUrl(String q) {
  //user inputs the argument "#YOLO2018"
  String url = "https://example.com?query=" + q;
 
  return url;
}

For example, if the user supplies the input string "#YOLO2018<kitten>", the url returned is "https://example.com?query=#YOLO2018<kitten>" which is not a valid URL.

...

Code Block
bgColor#ccccff
String buildEncodedUrl(String q) {
    String origUrlencodedUrl = "https://example.com?query=" + q;
    String encodedUrl = Base64.getUrlEncoder().encodeToString(origUrlq.getBytes());
 
    return encodedUrl;
}

If the user supplies the input string "#YOLO2018", the url returned is "https%3A%2F%2Fexample.com%3Fquery%3D%23YOLO2018https://example.com?query=%3Ckitten%3E" which is a valid URL.

Applicability

...