mirror of
https://github.com/iptv-org/iptv
synced 2026-10-21 18:46:20 -04:00
fix: address nested playlist review feedback
This commit is contained in:
1 parent
e7e21e166c
commit
de096ff4a8
3 files changed
+13
-17
No files matched your search
+5
-7
@@ -45,17 +45,15 @@ export function normalizeURL(url: string): string {
|
||||
}
|
||||
|
||||
export function getStoragePath(filepath: string, rootDir: string): string {
|
||||
const relative = path.relative(path.resolve(rootDir), path.resolve(filepath))
|
||||
const root = path.resolve(rootDir)
|
||||
const target = path.resolve(path.isAbsolute(filepath) ? filepath : path.join(root, filepath))
|
||||
const relative = path.relative(root, target)
|
||||
|
||||
if (relative && relative !== '..' && !relative.startsWith(`..${path.sep}`)) {
|
||||
return relative
|
||||
}
|
||||
|
||||
if (path.isAbsolute(filepath) || filepath === '..' || filepath.startsWith(`..${path.sep}`)) {
|
||||
if (relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
|
||||
throw new Error(`Filepath "${filepath}" is outside the storage directory`)
|
||||
}
|
||||
|
||||
return filepath
|
||||
return relative
|
||||
}
|
||||
|
||||
export function truncate(string: string, limit: number = 100) {
|
||||
|
||||
Reference in new issue
Block a user