Resolve "." and ".." in a URI.
@exclude
555573
public static String normalizeURI( String uri )
    {
        //
        // If it's a relative URI, normalize it.  Note that we don't want to create a URI
        // (very expensive) unless we think we'll need to.  "./" catches "../" and "./".
        //
        if ( uri.indexOf( "./" ) != -1 )
        {
            try
            {
                uri = new URI( uri ).normalize().toString();
            }
            catch ( URISyntaxException e )
            {
                logger.error( "Could not parse relative URI " + uri );
            }
        }
        
        return uri;
    }
291286
function resolveResource(ref, baseURI){
    // ref ~ "#123"
    if (/^#\d+$/.test(ref))
      return templateList[ref.substr(1)];

    // ref ~ "id:foo"
    if (/^id:/.test(ref))
      return resolveSourceByDocumentId(ref.substr(3));

    // ref ~ "foo.bar.baz"
    if (/^[a-z0-9\.]+$/i.test(ref) && !/\.tmpl$/.test(ref))
      return getSourceByPath(ref);

    // ref ~ "./path/to/file.tmpl"
    return basis.resource(basis.resource.resolveURI(ref, baseURI, '<b:include src=\"{url}\"/>'));
  }
751167
private static String getCidUriValue(String uri) {
		int colon = uri.indexOf(':');
		if (colon == 3) {
			String scheme = uri.substring(0, colon);
			return "cid".equalsIgnoreCase(scheme) ? uri.substring(colon + 1) : null;
		}

		if (uri.length() > 0 && uri.charAt(0) == '<' && uri.charAt(uri.length() - 1) == '>') {
			return uri.substring(1, uri.length() - 1);
		}

		return null;
	}
802714
public final String getExplicitPrefix(String uri)
    {
        if (mNsMapping != null) {
            String prefix = mNsMapping.findPrefixByUri(uri);
            if (prefix != null) {
                return prefix;
            }
        }
        if (mRootNsContext != null) {
            String prefix = mRootNsContext.getPrefix(uri);
            if (prefix != null) {
                // Hmmh... still can't use the default NS:
                if (prefix.length() > 0) {
                    return prefix;
                }
                // ... should we try to find an explicit one?
            }
        }
        return null;
    }
1045630
def uri_from_parts(parts):
    ""
    uri = "%s://%s%s" % (parts[0], parts[1], parts[2])
    if parts[3]:
        extra = '?'+urlencode(parts[3])
        uri += extra
    return uri
390474
function parse(uri) {
  var result = { baseUri: '', fragment: '#' };

  if (uri.slice(0, 4).toLowerCase() === 'urn:') {
    result.kind = 'urn';
    var parts = uri.match(URN_REGEX);
    if (parts) {
        result.baseUri = parts[1] + (parts[2] || '');
      result.host = parts[1];
      if (parts[2]) { result.pathname = parts[2]; }
      if (parts[3]) { result.fragment = parts[3]; }
    }
  } else {
    result.kind = 'url';
    var parsed = url.parse(uri);
    if (parsed.hash) {
      result.fragment = parsed.hash;
      delete parsed.hash;
    }
    result.absolute =
      (parsed.host && parsed.pathname && parsed.pathname[0] === '/') ?
      true : false;
    result.baseUri = url.format(parsed);
  }

  return result;
}
1221439
private String normalizeActionPath(Resource parent, String uri) {
        String relativeUri = extractRelativeUrl(uri, parent.getUri());
        if (!relativeUri.startsWith("/")) {
            relativeUri = "/" + relativeUri;
        }
        return relativeUri;
    }
52311
private static String ensureLeadingSlash(@Nullable String uri) {
        if (uri == null)
            return "/";
        return uri.startsWith("/") ? uri : "/" + uri;
    }
215574
protected String parseRequestUriWithoutContextPath(HttpServletRequest req){
        String requestUri = req.getRequestURI();
        String contextPath = req.getContextPath();
        requestUri = requestUri.substring(contextPath.length());
        if(requestUri.startsWith("/")){
            return requestUri;
        }else {
            return "/"+requestUri;
        }
    }
969296
public function resolveAssetUri(string $uri): ?string
    {
        $targetObject = $this->convertUriToObject($uri);
        if ($targetObject === null) {
            $this->systemLogger->info(sprintf('Could not resolve "%s" to an existing asset; The asset was probably deleted.', $uri), LogEnvironment::fromMethodName(__METHOD__));
            return null;
        }
        return $this->resourceManager->getPublicPersistentResourceUri($targetObject->getResource());
    }
1117586
private boolean isExcludedPath(String requestURI)
    {
        if (requestURI == null)
            return false;
        if (_excludedPaths != null)
        {
            for (String excludedPath : _excludedPaths)
            {
                if (requestURI.startsWith(excludedPath))
                {
                    return true;
                }
            }
        }
        if (_excludedPathPatterns != null)
        {
            for (Pattern pattern : _excludedPathPatterns)
            {
                if (pattern.matcher(requestURI).matches())
                {
                    return true;
                }
            }
        }
        return false;
    }
800403
function resolveUrl(headers, relativeURL) {
	var path = headers[":path"] || "";
	var baseUri = headers[":scheme"] + "://" + headers[":authority"] + path;

	var outURL;
	if (relativeURL && !fullUrlExp.test(relativeURL) ) {
		outURL = url.resolve(baseUri, relativeURL);
	} else {
		outURL = relativeURL;
	}
	return outURL;
}
956439
private function resolveBaseUriVar() {
        $envName = 'APP_BASE_URI';
        $envValue = null;

        if (!isset($_SERVER[$envName]))
            $envName = 'REDIRECT_'.$envName;

        while (isset($_SERVER[$envName])) {
            $envValue = $_SERVER[$envName];
            $envName = 'REDIRECT_'.$envName;
        }
        return $envValue;
    }
744593
private static String massageUri(String uriString) {
        if(!uriString.startsWith(SCHEMA_SPECIFIC_PREFIX)) {
            uriString = SCHEMA_SPECIFIC_PREFIX + uriString;
        }
        return uriString;
    }
1203059
private static String normalize(String url) {
        if (StringUtils.isBlank(url)) {
            return null;
        }
        // Strip "/tree/..."
        if (url.contains("/tree/")) {
            url = url.replaceFirst("/tree/.*$", "");
        }
        if (!url.endsWith("/")) {
            url += '/';
        }
        return url;
    }
878015
private boolean isExcluded(String uri) {
		if (excludeList == null || excludeList.isEmpty()) {
			return false;
		}

		for (String ex : excludeList) {
			if (uri.matches(ex)) {
				return true;
			}
		}
		return false;
	}
1364002
public static String getExtension(String uri) {
        if (uri == null) {
            return null;
        }

        int dot = uri.lastIndexOf(".");
        if (dot >= 0) {
            return uri.substring(dot);
        } else {
            // No extension.
            return "";
        }
    }