Normalizes given path by converting double frontslashes to singles
and removing the slashes from the beginning and end of the string.

@param  {String} path The path to normalize
@return {String}      Normalized path
487499
function normalizePath (path) {
		// Remove double slashes
		if (path.indexOf('//') !== -1) {
			path = path.replace(/\/+/g, '/');
		}

		// Shift slash
		if (path[0] === '/') {
			path = path.substr(1);
		}
		
		// Pop slash
		if (path[path.length - 1] === '/') {
			path = path.substr(0, path.length - 1);
		}

		return path;
	}
390149
def normalize_path(path, encoding='utf-8'):
    '''
    '''
    if not path.startswith('/'):
        path = '/' + path
    path = percent_encode(flatten_path(path, flatten_slashes=True), encoding=encoding)
    return uppercase_percent_encoding(path)
772163
public static String normalizePath(String path) {
    // remove double slashes & backslashes
    path = path.replace("//", "/");
    path = path.replace("\\", "/");

    // trim trailing slash from non-root path (ignoring windows drive)
    if (path.length() > 1 && path.endsWith("/")) {
      path = path.substring(0, path.length() - 1);
    }

    return path;
  }
721102
private static String normalize(final String path) {
        final StringBuilder builder = new StringBuilder(path);

        int index = 0;
        int colonIndex = -1;
        char current = 0;
        char last;

        while ((index > -1) && (index < builder.length())) {
            last = current;
            current = builder.charAt(index);

            switch (current) {
                case '}':
                    if (last == '\\')
                        break;
                    if (colonIndex != -1) {
                        builder.delete(colonIndex, index);
                        index = colonIndex;
                        colonIndex = -1;
                    }
                    break;
                case ':':
                    if (colonIndex == -1) {
                        colonIndex = index;
                    }
                    break;
            }

            if ((index == 0 || index == builder.length() - 1) && current == '/') {
                builder.deleteCharAt(index);
                if (index == builder.length()) {
                    // check again for path end
                    index--;
                }
            } else {
                index++;
            }
        }

        return builder.toString();
    }
1294762
function parsePath(path) {
        var lastSlash = path.lastIndexOf("/"), folder, rest;
        if (lastSlash === path.length - 1) {
            lastSlash = path.slice(0, path.length - 1).lastIndexOf("/");
        }
        if (lastSlash >= 0) {
            rest = " - " + (lastSlash ? path.slice(0, lastSlash) : "/");
            folder = path.slice(lastSlash + 1);
        } else {
            rest = "/";
            folder = path;
        }

        return {path: path, folder: folder, rest: rest};
    }
999623
function normalize(route) {
  const normalized = { ...route };

  if (is.not.array(normalized.path) && is.not.string(normalized.path)) {
    throw new Error("The route's path must be a String or [String]");
  }

  if (is.array(normalized.method)) {
    /* If method is an array */
    for (let method of normalized.method) {
      method = clean(method);
    }
  }

  /* If method is a string */
  if (is.string(normalized.method)) {
    normalized.method = clean(normalized.method);
  }

  return normalized;
}
1215390
public static String normalizeSlashes(final String path) {
        // prepare
        final StringBuilder builder = new StringBuilder(path);
        boolean modified = false;

        // remove all trailing '/'s except the first one
        while (builder.length() > 0 && builder.length() != 1 && PATH_SEPARATOR == builder.charAt(builder.length() - 1)) {
            builder.deleteCharAt(builder.length() - 1);
            modified = true;
        }

        // add a slash at the beginning if one isn't present
        if (builder.length() == 0 || PATH_SEPARATOR != builder.charAt(0)) {
            builder.insert(0, PATH_SEPARATOR);
            modified = true;
        }

        // only create string when it was modified
        if (modified) {
            return builder.toString();
        }

        return path;
    }
696592
function (path) {
        var str = path + ''
        var dotP = str.lastIndexOf('.') + 1
        return !dotP ? false : dotP !== str.length ? str.substr(dotP) : ''
      }
786296
private static String normalizePath(String absPath)
   {
      if (absPath.endsWith("/"))
      {
         return absPath.substring(0, absPath.length() - 1);
      }

      return absPath;
   }
154359
def normalize_path(path):
    
    if path in ['//', '/', '']:
        return '/'
    npath = normpath(unquote(path, exceptions=QUOTE_EXCEPTIONS['path']))
    if path[-1] == '/' and npath != '/':
        npath += '/'
    return npath
651312
static public function normalizePath($path)
    {
        $path = preg_replace('|/\./|', '/', $path);   // entferne /./
        $path = preg_replace('|^\./|', '', $path);    // entferne ./ am Anfang
        $i = 0;
        while (preg_match('|[^/]+/\.{2}/|', $path) && $i < 10) {
            $path = preg_replace_callback('|([^/]+)(/\.{2}/)|', function($matches){
                return ($matches[1] == '..' ? $matches[0] : '');
            }, $path);
            $i++;
        }
        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();
    }
1032592
def normalize_path(path):
    # type: (AnyStr) -> AnyStr
    

    return os.path.normpath(
        os.path.normcase(
            os.path.abspath(os.path.expandvars(os.path.expanduser(str(path))))
        )
    )
1243088
function fixPaths(paths) {
    return paths.map(path => {
        if (_.startsWith(path, '!./')) {
            return `!${path.substr(3)}`;
        } else if (_.startsWith(path, './')) {
            return path.substr(2);
        } else {
            return path;
        }
    });
}
352132
private String normalizePath(String path) {
		// 标准化路径
		path = FileUtil.normalize(path);
		path = StrUtil.removePrefix(path, StrUtil.SLASH);

		Assert.isFalse(FileUtil.isAbsolutePath(path), "Path [{}] must be a relative path !", path);
		return path;
	}
1314118
def _normalize_path(path):
        
        if isinstance(path, FileInfo):
            path = path.path
        if len(path) == 0:
            return '/'
        if not path.startswith('/'):
            path = '/' + path
        return path
37075
function normalize(p) {
    var isAbsolutePath = isAbsolute(p);
    var trailingSlash = p && p[p.length - 1] === '/';

    p = normalizeArray(p.split('/'), !isAbsolutePath).join('/');

    if (!p && !isAbsolutePath) {
      p += '.';
    }
    if (p && trailingSlash) {
      p += '/';
    }
    return (isAbsolutePath ? '/' : '') + p;
  }