Normalize a route path.  Ensures that the path begins with a '/'.
    If `allow_trailing` is False, strips off any trailing '/'.  Any
    repeated '/' characters in the path will be collapsed into a
    single one.
494340
def norm_path(path, allow_trailing=True):
    

    # Collapse slashes
    path = _path_re.sub('/', path)

    # Force a leading slash
    if path[0] != '/':
        path = '/' + path

    # Trim a trailing slash
    if not allow_trailing and path[-1] == '/':
        path = path[:-1]

    return path
833230
function normalizeResourcePath(path) {
    path = path || "";
    while (path.startsWith("/"))
        path = path.slice(1);
    while (path.endsWith("/"))
        path = path.slice(0, -1);
    return path;
}
582848
function normalize(path) {
  var last = path.length - 1
  var lastC = path.charAt(last)

  // If the uri ends with `#`, just return it without '#'
  if (lastC === "#") {
    return path.substring(0, last)
  }

  return (path.substring(last - 2) === ".js" ||
      path.substring(last - 3) === ".css" ||
      path.indexOf("?") > 0 ||
      lastC === "/") ? path : path + ".js"
}
1368373
private String normalizePath(String path) {
		// remove double slashes & backslashes
		path = path.replace("//", "/");
		path = path.replace("\\", "/");

		return path;
	}
1311699
public static String normalizePath(String path) {
		String retval = path;
		retval = retval.replaceAll(PathUtils.REGEX_MULTIPLE_SLASH,
				PathUtils.REGEX_SLASH);
		retval = retval.replaceAll(PathUtils.REGEX_BACKSLASH,
				PathUtils.REGEX_SLASH);
		return retval;
	}
431244
def _fix_path(self, path):
        
        if path.endswith('/'):
            path = path.rstrip('/')

        return safe_str(path)
509854
function normalizeSeparators (p) {
  p = p || "";

  if (path.sep === "\\") {
    // Replace backslashes with forward slashes
    return p.replace(/\\/g, "/");
  }
  else {
    // Return the path as-is, since it should already have proper URL separators.
    // If it DOES contain backslashes, then they are treated as normal characters,
    // NOT as separators
    return p;
  }
}
899345
function _normalizeUrl (route, prefix) {
  const _route = Object.assign({}, route)
  const url = _route.url
                 .replace(/^\//, '')
                 .replace(/\/$/, '')

  // build prefix
  prefix = prefix ? `/${prefix}` : ''
  _route.url = url ? `${prefix}/${url}/` : `${prefix}/`

  debug(`rewritting url: ${_route.url}`)

  return _route
}
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( '/' );
   }
277230
function normalizePathParts(parts) {

        // IMPORTANT: It is assumed that parts[0] === "" because this method is used to
        // join an absolute path to a relative path
        var i;
        var len = 0;

        var numParts = parts.length;

        for (i = 0; i < numParts; i++) {
            var part = parts[i];

            if (part === '.') {
                // ignore parts with just "."
                /*
                // if the "." is at end of parts (e.g. ["a", "b", "."]) then trim it off
                if (i === numParts - 1) {
                    //len--;
                }
                */
            } else if (part === '..') {
                // overwrite the previous item by decrementing length
                len--;
            } else {
                // add this part to result and increment length
                parts[len] = part;
                len++;
            }
        }

        if (len === 1) {
            // if we end up with just one part that is empty string
            // (which can happen if input is ["", "."]) then return
            // string with just the leading slash
            return '/';
        } else if (len > 2) {
            // parts i s
            // ["", "a", ""]
            // ["", "a", "b", ""]
            if (parts[len - 1].length === 0) {
                // last part is an empty string which would result in trailing slash
                len--;
            }
        }

        // truncate parts to remove unused
        parts.length = len;
        return parts.join('/');
    }
186321
private static String normalizePathInfo(String pPathInfo) {
        if (pPathInfo != null && pPathInfo.length() > 0) {
            return pPathInfo.startsWith("/") ? pPathInfo.substring(1) : pPathInfo;
        } else {
            return "";
        }
    }
851457
function (path) {
                var absolute = path.charAt(0) === '/', trailingSlash = path.slice(0 - 1) === '/';
                path = normalizeArray(splitPathToArray(path), !absolute).join('/');
                if (!path && !absolute) {
                    path = '.';
                }
                if (path && trailingSlash) {
                    path += '/';
                }
                return (absolute ? '/' : '') + 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;
  }
844564
protected String normalizePath(String repoPath)
   {
      if (repoPath.length() > 0 && repoPath.endsWith("/"))
      {
         return repoPath.substring(0, repoPath.length() - 1);
      }

      return repoPath;
   }
339640
function formatSubPath (path) {
  const trimmed = path.trim();
  // invalid leading 0
  if (path.charAt(0) === '0' && isNaN(path)) { return false }

  return isLiteral(trimmed) ? stripQuotes(trimmed) : '*' + trimmed
}
800944
@Restricted(NoExternalUse.class)
    public static String normalize(@Nonnull String path) {
        StringBuilder buf = new StringBuilder();
        // Check for prefix designating absolute path
        Matcher m = ABSOLUTE_PREFIX_PATTERN.matcher(path);
        if (m.find()) {
            buf.append(m.group(1));
            path = path.substring(m.end());
        }
        boolean isAbsolute = buf.length() > 0;
        // Split remaining path into tokens, trimming any duplicate or trailing separators
        List<String> tokens = new ArrayList<>();
        int s = 0, end = path.length();
        for (int i = 0; i < end; i++) {
            char c = path.charAt(i);
            if (c == '/' || c == '\\') {
                tokens.add(path.substring(s, i));
                s = i;
                // Skip any extra separator chars
                while (++i < end && ((c = path.charAt(i)) == '/' || c == '\\')) { }
                // Add token for separator unless we reached the end
                if (i < end) tokens.add(path.substring(s, s+1));
                s = i;
            }
        }
        if (s < end) tokens.add(path.substring(s));
        // Look through tokens for "." or ".."
        for (int i = 0; i < tokens.size();) {
            String token = tokens.get(i);
            if (token.equals(".")) {
                tokens.remove(i);
                if (tokens.size() > 0)
                    tokens.remove(i > 0 ? i - 1 : i);
            } else if (token.equals("..")) {
                if (i == 0) {
                    // If absolute path, just remove: /../something
                    // If relative path, not collapsible so leave as-is
                    tokens.remove(0);
                    if (tokens.size() > 0) token += tokens.remove(0);
                    if (!isAbsolute) buf.append(token);
                } else {
                    // Normalize: remove something/.. plus separator before/after
                    i -= 2;
                    for (int j = 0; j < 3; j++) tokens.remove(i);
                    if (i > 0) tokens.remove(i-1);
                    else if (tokens.size() > 0) tokens.remove(0);
                }
            } else
                i += 2;
        }
        // Recombine tokens
        for (String token : tokens) buf.append(token);
        if (buf.length() == 0) buf.append('.');
        return buf.toString();
    }
951266
def allowed_paths=(paths)
      if paths.is_a? String
        # Grab everything between commas that aren't escaped with a backslash
        paths = paths.to_s.split(/(?<!\\),\ ?/).map do |path|
          path.strip.gsub('\,', ',') # remove the escape characters
        end
      end

      @allowed_paths = paths
    end