Helper function to normalize a file path for comparison. Makes all slashes forward slashes, removes trailing and redundant slashes, and resolves "." and "..".
188233
function normalizePath(path) {
    // Separate the path into parts (delimited by slashes)
    let parts = [""];
    for (let char of path) {
        if (char === "/" || char === "\\") {
            if (parts[parts.length - 1].length) {
                parts.push("");
            }
        }
        else {
            parts[parts.length - 1] += char;
        }
    }
    // Special case for when the entire path was "."
    if (parts.length === 1 && parts[0] === ".") {
        return ".";
    }
    // Resolve "." and ".."
    let i = 0;
    while (i < parts.length) {
        if (parts[i] === ".") {
            parts.splice(i, 1);
        }
        else if (i > 0 && parts[i] === "..") {
            parts.splice(i - 1, 2);
            i--;
        }
        else {
            i++;
        }
    }
    // Build the resulting path
    let result = "";
    for (let part of parts) {
        if (part && part.length) {
            if (result.length) {
                result += "/";
            }
            result += part;
        }
    }
    // Retain a slash at the beginning of the string
    if (path[0] === "/" || path[0] === "\\") {
        result = "/" + result;
    }
    // All done!
    return result;
}
653561
def normalizeFilePath(value):
    
    if not isinstance(value, basestring):
        raise TypeError("File paths must be strings, not %s."
                        % type(value).__name__)
    return unicode(value)
311256
function normalize$1(path) {
              var isPathAbsolute = isAbsolute(path),
                  trailingSlash = substr(path, -1) === '/';

              // Normalize the path
              path = normalizeArray(filter(path.split('/'), function(p) {
                return !!p;
              }), !isPathAbsolute).join('/');

              if (!path && !isPathAbsolute) {
                path = '.';
              }
              if (path && trailingSlash) {
                path += '/';
              }

              return (isPathAbsolute ? '/' : '') + path;
            }
766283
def normalize_path(filename):
    """"""
    return os.path.normcase(os.path.realpath(os.path.normpath(_cygwin_patch(filename))))
951976
def normalize_path(url)
      url = URI(url)
      (url.path.start_with?('/') ? url.path : '/' + url.path) +
        (url.query ? "?#{sort_query_params(url.query)}" : '')
    end
126851
def proper_path(path):
    
    if path.startswith("./"):
        pass
    elif path.startswith("/"):
        path = ".%s" % path
    elif path.startswith("."):
        while path.startswith("."):
            path = path[1:]
        if path.startswith("/"):
            path = ".%s" % path
    else:
        path = "./%s" % path

    if not path.endswith("/"):
        path += "/"

    return path
1028827
function stripCommonPath(paths) {
  var prefix = commonPrefix(paths);
  var prefixLength = prefix.lastIndexOf('/') + 1;

  return paths.map(function(str) {
    return str.slice(prefixLength);
  });
}
1103365
function _normalizePath(path, parent, ancestors) {
    if (path === '/') {
        return path;
    }

    path = path.replace(/\/$/, '');

    // If path begins with / then assume it is independent route
    if (path[0] === '/') {
        return path;
    }

    // If no parent, and route doesn't start with /, then prepend /
    if (! parent) {
        return `/${path}`;
    }

    if (ancestors) {
        return _cleanPath(`${ancestors.join('/')}/${path}`);
    }

    return _cleanPath(`${parent.path}/${path}`);
}
1368373
private String normalizePath(String path) {
		// remove double slashes & backslashes
		path = path.replace("//", "/");
		path = path.replace("\\", "/");

		return path;
	}
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;
	}
934173
function normalize(path) {
  if (!path) {
    return '/';
  }
  if (path[0] !== '/') {
    path = '/' + path;
  }
  if (path[path.length - 1] !== '/') {
    path = path + '/';
  }
  return path;
}
969431
public static String normalizePath(String path)
    {
        StringBuilder sb = new StringBuilder(path);
        int lastToken = -1;
        for (int i = 0; i < sb.length(); i++)
        {
            if ((sb.charAt(i) == File.separatorChar)
                || (sb.charAt(i) == '/'))
            {
                if (lastToken != -1)
                {
                    if (i < sb.length() - 2)
                        if (sb.charAt(i + 1) == '.')
                            if (sb.charAt(i + 2) == '.')
                    {   // Remove last directory name from path
                        sb.delete(lastToken, i + 3);
                        i = lastToken;
                    }
                }
                lastToken = i;
            }
        }
        return sb.toString();
    }
23991
protected String normalizePath(String path) {

        if (path.equals("/")) {
            return path;
        } else {
            return CmsFileUtil.removeTrailingSeparator(path);
        }

    }
904592
function normalize(filepath) {

    // resolve to an absolute ppath
    if (!path.isAbsolute || !path.isAbsolute(filepath))
        filepath = path.resolve(path.dirname(module.parent.filename), filepath);

    // tack .json on the end if need be
    if (!/\.json$/.test(filepath))
        filepath = filepath + '.json';

    return filepath;
}
651893
function( path ) {
      var normalized = [];
      var parts = path.split( '/' );

      for( var i = 0; i < parts.length; i++ ) {
         if( parts[i] === '.' ) {
            continue;
         }

         if( parts[i] === '..' && normalized.length && normalized[normalized.length - 1] !== '..' ) {
            normalized.pop();
            continue;
         }

         normalized.push( parts[i] );
      }

      return normalized.join( '/' );
   }
1344886
private String normalizePath(String path) {

		// remove leading and tailing whitespaces
		path = path.trim();

		// remove consecutive slashes & backslashes
		path = path.replace("\\", "/");
		path = path.replaceAll("/+", "/");

		// remove tailing separator
		if (path.endsWith(SEPARATOR) &&
				!path.equals(SEPARATOR) &&              // UNIX root path
				!WINDOWS_ROOT_DIR_REGEX.matcher(path).matches()) {  // Windows root path)

			// remove tailing slash
			path = path.substring(0, path.length() - SEPARATOR.length());
		}

		return path;
	}
1140098
function normalizeFilepath(filepath) {
    filepath = filepath.replace(/\\/g, "/");
    filepath = filepath.replace(/^\.\//, "");
    return filepath;
}