Translate Windows %-style variables

This commit is contained in:
mtkennerly 2022-09-18 06:40:02 +08:00
parent e25062de36
commit 202879f7d3
No known key found for this signature in database
GPG key ID: E764BE00BE6E6408
2 changed files with 112 additions and 118 deletions

View file

@ -318,7 +318,13 @@ function parsePath(path: string): [string, PathType] {
.replace(/\\/g, "/")
.replace(/\/{2,}/g, "/")
.replace(/\/(?=$)/g, "")
.replace(/^~(?=($|\/))/, "<home>");
.replace(/^~(?=($|\/))/, "<home>")
.replace(/%userprofile%[/\\]AppData[/\\]Roaming/i, "<winAppData>")
.replace(/%userprofile%[/\\]AppData[/\\]Local(?!Low)/i, "<winLocalAppData>")
.replace(/%userprofile%[/\\]Documents/i, "<winDocuments>")
.replace(/%userprofile%/i, "<home>")
.replace(/%appdata%/i, "<winAppData>")
.replace(/%localappdata%/i, "<winLocalAppData>");
while (path.endsWith("/*")) {
path = path.slice(0, path.length - 2);