Skip to content

Instantly share code, notes, and snippets.

@cx0der
Created May 18, 2019 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cx0der/c1aa309bce4bb48e1142ddbf72f11fac to your computer and use it in GitHub Desktop.
Save cx0der/c1aa309bce4bb48e1142ddbf72f11fac to your computer and use it in GitHub Desktop.
Resolving resource
private String resolveResource(String requestedPath) {
Path resolvedPath = FileSystems.getDefault().getPath("");
Path other = FileSystems.getDefault().getPath(requestedPath);
for (Path path : other) {
if (!path.startsWith(".") && !path.startsWith("..")) {
resolvedPath = resolvedPath.resolve(path);
}
}
if (resolvedPath.startsWith("")) {
resolvedPath = resolvedPath.resolve(INDEX_HTML);
}
return resolvedPath.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment