Normalizes two paths and joins them as a single path.

@param prefix
@param path
@return the joined path
551518
public static String joinPaths(String prefix, String path, boolean generatedPath) {

		String result = null;
		if (generatedPath) {
			result = joinDomainToPath(prefix, path);
		} else {
			result = joinPaths(prefix, path);
		}
		return result;
	}
1260611
def path(self, *path):
        """"""
        path = list(filter(None, path))
        path = self.unprefix(path)
        items = [self.prefix_] + path
        return self.join(*items)
846139
protected static String normalizePath (String path) {
    int pathLen;
    do {
      pathLen = path.length();
      path = path.replaceAll("[^/]+/\\.\\./", "");
    } while (path.length() != pathLen);
    return path;
  }
63786
private String normalizePath(final String subPath) {
        if(subPath == null) {
            return "";
        }
        
        String value = subPath.trim();
        if(value.isEmpty()) {
            return value;
        }
        
        if(value.startsWith(PATH_SEPARATOR)) {
            value = value.substring(1);
        }
        
        if(value.endsWith(PATH_SEPARATOR)) {
            value = value.substring(0, value.length()-1);
        }
        
        return value;
        
    }
485427
public void addMergePath(PathImpl path)
  {
    if (! (path instanceof MergePath)) {
      // Need to normalize so directory paths ends with a "./"
      // XXX:
      //if (path.isDirectory())
      //  path = path.lookup("./");

      ArrayList<PathImpl> pathList = ((MergePath) _root)._pathList;

      if (! pathList.contains(path))
        pathList.add(path);
    }
    else if (((MergePath) path)._root == _root)
      return;
    else {
      MergePath mergePath = (MergePath) path;
      ArrayList<PathImpl> subPaths = mergePath.getMergePaths();
      String pathName = "./" + mergePath._pathname + "/";

      for (int i = 0; i < subPaths.size(); i++) {
        PathImpl subPath = subPaths.get(i);

        addMergePath(subPath.lookup(pathName));
      }
    }
  }
57478
public static String appendPath(String prefixPath, String subpath) {
        return cleanPath(prefixPath) + SEPARATOR + cleanPath(subpath);
    }
866758
public static String joinPath(String path1, String path2) {
        return path1 + Constants.SEP_STRING + path2;
    }
305309
public static String concatPaths(@Nullable String path1, @Nullable String path2) {
        path2 = path2 == null ? "" : path2;

        if (path1 == null || path1.isEmpty() || EMPTY_REQUEST_PATH.equals(path1)) {
            if (path2.isEmpty()) {
                return EMPTY_REQUEST_PATH;
            }

            if (path2.charAt(0) == '/') {
                return path2; // Most requests will land here.
            }

            return new StringBuilder(path2.length() + 1)
                    .append('/').append(path2).toString();
        }

        // At this point, we are sure path1 is neither empty nor null.
        if (path2.isEmpty()) {
            // Only path1 is non-empty. No need to concatenate.
            return path1;
        }

        if (path1.charAt(path1.length() - 1) == '/') {
            if (path2.charAt(0) == '/') {
                // path1 ends with '/' and path2 starts with '/'.
                // Avoid double-slash by stripping the first slash of path2.
                return new StringBuilder(path1.length() + path2.length() - 1)
                        .append(path1).append(path2, 1, path2.length()).toString();
            }

            // path1 ends with '/' and path2 does not start with '/'.
            // Simple concatenation would suffice.
            return new StringBuilder(path1.length() + path2.length())
                    .append(path1).append(path2).toString();
        }

        if (path2.charAt(0) == '/') {
            // path1 does not end with '/' and path2 starts with '/'.
            // Simple concatenation would suffice.
            return path1 + path2;
        }

        // path1 does not end with '/' and path2 does not start with '/'.
        // Need to insert '/' between path1 and path2.
        return new StringBuilder(path1.length() + path2.length() + 1)
                .append(path1).append('/').append(path2).toString();
    }
836871
def normalize_path(path, relative_to=os.getcwd()):

    """"""

    path = os.path.expanduser(os.path.normpath(path))

    if os.path.isabs(path):
        return path
    else:
        return join(relative_to, path)
868217
@Override
	public boolean matchPath(String path) {

		boolean match = false;
		if (StringUtils.isNotEmpty(path)) {
			match = path.startsWith(prefix);
		}
		return match;
	}
142470
public Routed<T> route(String path) {
    final String[]            tokens  = Pattern.removeSlashAtBothEnds(path).split("/");
    final Map<String, String> params  = new HashMap<String, String>();
    boolean                   matched = true;

    for (final Pattern<T> pattern : patterns) {
      final String[] currTokens = pattern.tokens();
      final T        target     = pattern.target();

      matched = true;
      params.clear();

      if (tokens.length == currTokens.length) {
        for (int i = 0; i < currTokens.length; i++) {
          final String token     = tokens[i];
          final String currToken = currTokens[i];

          if (currToken.length() > 0 && currToken.charAt(0) == ':') {
            params.put(currToken.substring(1), token);
          } else if (!currToken.equals(token)) {
            matched = false;
            break;
          }
        }
      } else if (currTokens.length > 0 && currTokens[currTokens.length - 1].equals(":*") && tokens.length >= currTokens.length) {
        for (int i = 0; i < currTokens.length - 1; i++) {
          final String token     = tokens[i];
          final String currToken = currTokens[i];

          if (currToken.length() > 0 && currToken.charAt(0) == ':') {
            params.put(currToken.substring(1), token);
          } else if (!token.equals(token)) {
            matched = false;
            break;
          }
        }

        if (matched) {
          final StringBuilder b = new StringBuilder(tokens[currTokens.length - 1]);
          for (int i = currTokens.length; i < tokens.length; i++) {
            b.append('/');
            b.append(tokens[i]);
          }
          params.put("*", b.toString());
        }
      } else {
        matched = false;
      }

      if (matched) return new Routed<T>(target, false, params);
    }

    if (notFound != null) {
      params.clear();
      return new Routed<T>(notFound, true, params);
    }

    return null;
  }
831213
public <T extends Normalizer> T restore(@NonNull String path) throws Exception {
        try (InputStream in = new BufferedInputStream(new FileInputStream(path))) {
            return restore(in);
        }
    }
313436
private static Path normalizePath(Path path) {
		URI uri = path.toUri();
		if (uri.getScheme() == null) {
			try {
				uri = new URI("file", uri.getHost(), uri.getPath(), uri.getFragment());
				path = new Path(uri.toString());
			} catch (URISyntaxException e) {
				throw new IllegalArgumentException("path is invalid", e);
			}
		}
		return path;
	}
892493
static public String normalize(String path) {
    if (path == null || path.length() == 0) return ROOT;
    
    if (path.charAt(0) != PATH_SEPARATOR) {
      throw new IllegalArgumentException(
                                         "Network Location path does not start with "
                                         +PATH_SEPARATOR_STR+ ": "+path);
    }
    
    int len = path.length();
    if (path.charAt(len-1) == PATH_SEPARATOR) {
      return path.substring(0, len-1);
    }
    return path;
  }
1106018
public static String joinZKPath(String path, String name) {
        if (path.endsWith("/")) {
            return path + name;
        } else {
            return path + "/" + name;
        }
    }
186887
public static String join(final String path1, final String path2) {
        if (path1.isEmpty() && path2.isEmpty()) return "";
        if (path1.isEmpty() && !path2.isEmpty()) return path2;
        if (path2.isEmpty() && !path1.isEmpty()) return path1;
        final StringBuilder sb = new StringBuilder(DEFAULT_BUFFER_SIZE);
        sb.append(path1);
        if (sb.charAt(sb.length() - 1) == '/') sb.setLength(sb.length() - 1);
        if (path2.charAt(0) != '/') sb.append('/');
        sb.append(path2);
        return sb.toString();
    }
776297
def NormalizeRelativePath(path):
        """"""
        path_components = path.split('/')
        normalized_components = []
        for component in path_components:
            if re.match(r'{[A-Za-z0-9_]+}$', component):
                normalized_components.append(
                    '{%s}' % Names.CleanName(component[1:-1]))
            else:
                normalized_components.append(component)
        return '/'.join(normalized_components)