Normalizes a path and adds a separator at its start, if it's not a
generated resource.

@param path
the path
@param generatedResource
the flag indicating if the resource has been generated
@return the normalized path
427850
private String asPath(String path, boolean generatedResource) {

		String result = path;
		if (!generatedResource) {
			result = PathNormalizer.asPath(path);
		}
		return result;
	}
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;
}
392242
public static String normalizeDirPath(String dirPath) {
        if (dirPath == null || dirPath.isEmpty())
            return "";

        dirPath = dirPath.replace("\\", "/");

        if (!dirPath.endsWith("/")) {
            dirPath = dirPath + "/";
        }

        return dirPath;
    }
469350
@Override
	protected Reader generateResource(String path, GeneratorContext context) {

		Reader reader = helper.createResource(context);

		String filePath = helper.getFilePath(path);
		if (filePath != null) {
			long lastModified = rsHandler.getLastModified(filePath);
			FilePathMapping fMapping = new FilePathMapping(filePath, lastModified);
			addLinkedResources(path, context, Arrays.asList(fMapping));
		}

		return reader;
	}
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;
        
    }
971603
static protected String normalizePath(String oldPath,
                                        String newPath,
                                        int offset,
                                        char separatorChar)
  {
    CharBuffer cb = new CharBuffer();
    normalizePath(cb, oldPath, newPath, offset, separatorChar);
    return cb.toString();
  }
372603
public static final String normalizePath(String path) {
		String normalizedPath = path.replaceAll("//", JawrConstant.URL_SEPARATOR);
		StringTokenizer tk = new StringTokenizer(normalizedPath, JawrConstant.URL_SEPARATOR);
		StringBuilder sb = new StringBuilder();
		while (tk.hasMoreTokens()) {
			sb.append(tk.nextToken());
			if (tk.hasMoreTokens())
				sb.append(JawrConstant.URL_SEPARATOR);
		}
		return sb.toString();

	}
826106
@Override
	public String getFilePath(String resourcePath) {

		String filePath = null;
		List<ResourceBrowser> list = new ArrayList<>();
		list.addAll(resourceInfoProviders);
		for (Iterator<ResourceBrowser> iterator = list.iterator(); iterator.hasNext() && filePath == null;) {
			ResourceBrowser rsBrowser = iterator.next();
			if (generatorRegistry.isPathGenerated(resourcePath)) {
				if (rsBrowser instanceof ResourceGenerator) {
					ResourceGenerator rsGeneratorBrowser = (ResourceGenerator) rsBrowser;
					if (rsGeneratorBrowser.getResolver().matchPath(resourcePath)) {
						filePath = rsBrowser.getFilePath(resourcePath);
					}
				}
			} else {
				if (!(rsBrowser instanceof ResourceGenerator)) {
					filePath = rsBrowser.getFilePath(resourcePath);
				}
			}
		}
		return filePath;
	}
1266566
@Override
	public String getResourcePath(String basePath, String relativePath) {

		String result = null;
		if (binaryGeneratorRegistry.isGeneratedBinaryResource(relativePath)) {
			result = relativePath;
		} else if (contextPath != null && relativePath.startsWith(contextPath)) {
			result = relativePath.substring(contextPath.length() - 1);
		} else {
			result = PathNormalizer.concatWebPath(basePath, relativePath);
		}
		return result;
	}
150728
@Override
	public Set<String> getResourceNames(String path) {
		path = path.replace('/', File.separatorChar);
		File resource = new File(baseDir, path);
		return FileUtils.getResourceNames(resource);
	}
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;
  }
695316
public static String getPathForResource(final String resourcePath) {
        URL path = ResourceUtil.class.getResource(resourcePath);
        if (path == null) {
            path = ResourceUtil.class.getResource("/");
            File tmpFile = new File(path.getPath(), resourcePath);
            return tmpFile.getPath();
        }

        return path.getPath();
    }
1150512
private static InputStream getStreamFromClassPath(
      final String normalizedPath) {
    InputStream dictInputStream = null;
    final String[] dictPaths = normalizedPath.split("src/main/resources");
    if (dictPaths.length == 2) {
      dictInputStream = IOUtils.class.getClassLoader()
          .getResourceAsStream(dictPaths[1]);
    } else {
      final String[] windowsPaths = normalizedPath
          .split("src\\\\main\\\\resources\\\\");
      if (windowsPaths.length == 2) {
        dictInputStream = IOUtils.class.getClassLoader()
            .getResourceAsStream(windowsPaths[1]);
      }
    }
    return dictInputStream;
  }
169952
public Resource addPath(String path)
        throws IOException,MalformedURLException
    {
        FileResource r=null;

        if (!isDirectory())
        {
            r=(FileResource)super.addPath(path);
        }
        else
        {
            path = org.browsermob.proxy.jetty.util.URI.canonicalPath(path);
            
            // treat all paths being added as relative
            String rel=path;
            if (path.startsWith("/"))
                rel = path.substring(1);
            
            File newFile = new File(_file,rel.replace('/', File.separatorChar));
            r=new FileResource(newFile.toURI().toURL(),null,newFile);
        }
        
        String encoded= org.browsermob.proxy.jetty.util.URI.encodePath(path);
        int expected=r._urlString.length()-encoded.length();
        int index = r._urlString.lastIndexOf(encoded, expected);
        
        if (expected!=index && ((expected-1)!=index || path.endsWith("/") || !r.isDirectory()))
        {
            r._alias=r._url;
            r._aliasChecked=true;
        }                   
        return r;
    }
257517
public static String getFolderPath(final String path) {

		String cleanedPath = clean(path);

		if (cleanedPath != null && cleanedPath.contains(PATH_SEP)) {

			return PATH_SEP + StringUtils.substringBeforeLast(cleanedPath, PATH_SEP);

		} else {

			return PATH_SEP;

		}
	}
445035
protected String normalizeExportPath(String exportPath) {

        String result = insertContextStrings(exportPath);
        result = OpenCms.getSystemInfo().getAbsoluteRfsPathRelativeToWebApplication(result);
        if (result.endsWith(File.separator)) {
            // ensure export path does NOT end with a File.separator
            result = result.substring(0, result.length() - 1);
        }
        return result;
    }
1079646
public static LocalFileResource newResource(String normalizedPath, String repositoryPath) {
        return new LocalFileResource(normalizedPath, repositoryPath, null);
    }