1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

improving absolute path checking

This commit is contained in:
Patrik J. Braun 2019-12-10 11:25:26 +01:00
parent f3cd6e5b34
commit 1685f4ed28

View File

@ -13,16 +13,12 @@ class ProjectPathClass {
this.reset(); this.reset();
} }
isAbsolutePath(pathStr: string) {
return path.resolve(pathStr) === path.normalize(pathStr);
}
normalizeRelative(pathStr: string) { normalizeRelative(pathStr: string) {
return path.join(pathStr, path.sep); return path.join(pathStr, path.sep);
} }
getAbsolutePath(pathStr: string): string { getAbsolutePath(pathStr: string): string {
return this.isAbsolutePath(pathStr) ? pathStr : path.join(this.Root, pathStr); return path.isAbsolute(pathStr) ? pathStr : path.join(this.Root, pathStr);
} }
getRelativePathToImages(pathStr: string): string { getRelativePathToImages(pathStr: string): string {