Dart API Referencedart:uri

dart:uri library

Methods

Code String decodeUri(String uri) #

An implementation of JavaScript's decodeURIComponent function. Decodes a Uniform Resource Identifier uri previously created by encodeURI or by a similar routine. It replaces each escape sequence in uri with the character that it represents. It does not decode escape sequences that could not have been introduced by encodeURI. It returns the unescaped URI.

String decodeUri(String uri) {
  return _uriDecode(uri);
}

Code String decodeUriComponent(String encodedComponent) #

An implementation of JavaScript's decodeURIComponent function. Decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine. It returns the unescaped string.

String decodeUriComponent(String encodedComponent) {
  return _uriDecode(encodedComponent);
}

Code String encodeUri(String uri) #

A JavaScript-like URI encoder. Encodes Uniform Resource Identifier uri by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two "surrogate" characters). This assumes that uri is a complete URI, so does not encode reserved characters that have special meaning in the URI: #;,/?:@&=+\$ It returns the escaped URI.

String encodeUri(String uri) {
  return _uriEncode(
    "-_.!~*'()#;,/?:@&=+\$0123456789"
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", uri);
}

Code String encodeUriComponent(String component) #

A javaScript-like URI component encoder, this encodes a URI component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two "surrogate" characters). To avoid unexpected requests to the server, you should call encodeURIComponent on any user-entered parameters that will be passed as part of a URI. For example, a user could type "Thyme &time=again" for a variable comment. Not using encodeURIComponent on this variable will give comment=Thyme%20&time=again. Note that the ampersand and the equal sign mark a new key and value pair. So instead of having a POST comment key equal to "Thyme &time=again", you have two POST keys, one equal to "Thyme " and another (time) equal to again. It returns the escaped string.

String encodeUriComponent(String component) {
  return _uriEncode(
    "-_.!~*'()0123456789"
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", component);
}

Code String merge(String base, String reference) #

String merge(String base, String reference) {
  if (base == "") return "/$reference";
  return "${base.substring(0, base.lastIndexOf("/") + 1)}$reference";
}

Code String removeDotSegments(String path) #

String removeDotSegments(String path) {
  List<String> output = [];
  bool appendSlash = false;
  for (String segment in path.split("/")) {
    appendSlash = false;
    if (segment == "..") {
      if (!output.isEmpty() &&
          ((output.length != 1) || (output[0] != ""))) output.removeLast();
      appendSlash = true;
    } else if ("." == segment) {
      appendSlash = true;
    } else {
      output.add(segment);
    }
  }
  if (appendSlash) output.add("");
  return Strings.join(output, "/");
}

Classes

Uri