mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
fixed review findings
This commit is contained in:
@@ -59,14 +59,26 @@ const normalizePath = (path: string) => {
|
||||
stack.push(part)
|
||||
}
|
||||
}
|
||||
return stack.join("/")
|
||||
const normalizedPath = stack.join("/")
|
||||
if (normalizedPath.startsWith("/")) {
|
||||
return normalizedPath;
|
||||
}
|
||||
return "/" + normalizedPath;
|
||||
};
|
||||
|
||||
const isAbsolute = (link: string) => {
|
||||
return link.startsWith("/");
|
||||
};
|
||||
|
||||
const isSubDirectoryOf = (basePath: string, currentPath: string) => {
|
||||
return currentPath.startsWith(basePath);
|
||||
};
|
||||
|
||||
export const createLocalLink = (basePath: string, currentPath: string, link: string) => {
|
||||
if (link.startsWith("/")) {
|
||||
if (isAbsolute(link)) {
|
||||
return join(basePath, link);
|
||||
}
|
||||
if (!currentPath.startsWith(basePath)) {
|
||||
if (!isSubDirectoryOf(basePath, currentPath)) {
|
||||
return join(basePath, link);
|
||||
}
|
||||
let path = currentPath;
|
||||
|
||||
Reference in New Issue
Block a user