Fix external library path validation #8319 (#8366)

* Fix isImmichPath

* prettier write

* Fis isImmichPath code comment

* Refactor isImmichPath function based on team suggestions

* Test isImmichPath

* fix: clean comments

* Refactor isImmichPath test based on team suggestions

* Clean code with lintern suggestions
This commit is contained in:
Pablo Diz
2024-03-31 16:47:03 +02:00
committed by GitHub
parent 34cbb18ecd
commit 6a4bc777a2
2 changed files with 36 additions and 1 deletions

View File

@@ -115,7 +115,13 @@ export class StorageCore {
}
static isImmichPath(path: string) {
return resolve(path).startsWith(resolve(APP_MEDIA_LOCATION));
const resolvedPath = resolve(path);
const resolvedAppMediaLocation = resolve(APP_MEDIA_LOCATION);
const normalizedPath = resolvedPath.endsWith('/') ? resolvedPath : resolvedPath + '/';
const normalizedAppMediaLocation = resolvedAppMediaLocation.endsWith('/')
? resolvedAppMediaLocation
: resolvedAppMediaLocation + '/';
return normalizedPath.startsWith(normalizedAppMediaLocation);
}
static isGeneratedAsset(path: string) {