Mark some Mac paths as too broad and normalize paths ending with *

This commit is contained in:
mtkennerly 2022-08-19 23:48:30 +08:00
parent 92fcbe1f1d
commit faf32b040a
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
2 changed files with 86 additions and 100 deletions

View file

@ -314,14 +314,17 @@ function parsePath(path: string): [string, PathType] {
}
}
return [
path
.replace(/\\/g, "/")
.replace(/\/{2,}/g, "/")
.replace(/\/(?=$)/g, "")
.replace(/^~(?=($|\/))/, "<home>"),
pathType,
];
path = path
.replace(/\\/g, "/")
.replace(/\/{2,}/g, "/")
.replace(/\/(?=$)/g, "")
.replace(/^~(?=($|\/))/, "<home>");
while (path.endsWith("/*")) {
path = path.slice(0, path.length - 2);
}
return [path, pathType];
}
export function pathIsTooBroad(path: string): boolean {
@ -343,6 +346,8 @@ export function pathIsTooBroad(path: string): boolean {
"<home>/AppData/Roaming",
"<home>/Documents/My Games",
"<winDocuments>/My Games",
"<home>/Library/Application Support",
"<home>/Library/Preferences",
].includes(path)) {
return true;
}