@lvce-editor/quick-pick-worker 4.33.0 → 4.33.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/quickPickWorkerMain.js +30 -14
- package/package.json +1 -1
|
@@ -3549,20 +3549,23 @@ const getWorkspaceDisplayPath = workspace => {
|
|
|
3549
3549
|
};
|
|
3550
3550
|
}
|
|
3551
3551
|
const url = new URL(workspace);
|
|
3552
|
+
const uriPrefix = url.search || url.hash || !url.pathname.startsWith('/') ? undefined : `${url.protocol}//${url.host}${trimTrailingSeparators(url.pathname)}/`;
|
|
3552
3553
|
return {
|
|
3553
3554
|
host: url.host,
|
|
3554
3555
|
path: decodeURIComponent(url.pathname),
|
|
3555
|
-
scheme: url.protocol
|
|
3556
|
+
scheme: url.protocol,
|
|
3557
|
+
uriPrefix,
|
|
3558
|
+
url
|
|
3556
3559
|
};
|
|
3557
3560
|
};
|
|
3558
|
-
const
|
|
3559
|
-
|
|
3560
|
-
if (hasUriScheme(uri)) {
|
|
3561
|
+
const isSafeRelativePath = path => /^[a-z\d._~/-]+$/i.test(path) && path.split('/').every(segment => segment !== '.' && segment !== '..');
|
|
3562
|
+
const getRelativeDirectory = (workspacePath, uri, dirName, isWorkspaceRelative) => {
|
|
3563
|
+
if (!isWorkspaceRelative && hasUriScheme(uri)) {
|
|
3561
3564
|
const url = new URL(uri);
|
|
3562
3565
|
if (workspacePath.scheme !== url.protocol || workspacePath.host !== url.host) {
|
|
3563
3566
|
return dirName;
|
|
3564
3567
|
}
|
|
3565
|
-
} else if (workspacePath.scheme) {
|
|
3568
|
+
} else if (!isWorkspaceRelative && workspacePath.scheme) {
|
|
3566
3569
|
return dirName;
|
|
3567
3570
|
}
|
|
3568
3571
|
const normalizedWorkspace = trimTrailingSeparators(workspacePath.path);
|
|
@@ -3576,15 +3579,18 @@ const getRelativeDirectory = (workspace, uri, dirName) => {
|
|
|
3576
3579
|
}
|
|
3577
3580
|
return normalizedDirectory.slice(prefix.length);
|
|
3578
3581
|
};
|
|
3579
|
-
const resolveFileUri = (workspace, path) => {
|
|
3582
|
+
const resolveFileUri = (workspace, path, workspacePath) => {
|
|
3580
3583
|
if (hasUriScheme(path)) {
|
|
3581
3584
|
return path;
|
|
3582
3585
|
}
|
|
3583
|
-
if (
|
|
3584
|
-
|
|
3586
|
+
if (workspacePath.url) {
|
|
3587
|
+
if (workspacePath.uriPrefix && !isAbsolutePath(path) && isSafeRelativePath(path)) {
|
|
3588
|
+
return `${workspacePath.uriPrefix}${path}`;
|
|
3589
|
+
}
|
|
3590
|
+
const workspaceUrl = new URL(workspacePath.url);
|
|
3585
3591
|
const normalizedPath = path.replaceAll('\\', '/').replaceAll('%', '%25');
|
|
3586
|
-
const
|
|
3587
|
-
workspaceUrl.pathname = normalizedPath.startsWith('/') ? normalizedPath : `${
|
|
3592
|
+
const workspaceUrlPath = trimTrailingSeparators(workspaceUrl.pathname);
|
|
3593
|
+
workspaceUrl.pathname = normalizedPath.startsWith('/') ? normalizedPath : `${workspaceUrlPath}/${normalizedPath}`;
|
|
3588
3594
|
return workspaceUrl.href;
|
|
3589
3595
|
}
|
|
3590
3596
|
if (isAbsolutePath(path)) {
|
|
@@ -3592,11 +3598,17 @@ const resolveFileUri = (workspace, path) => {
|
|
|
3592
3598
|
}
|
|
3593
3599
|
return `${trimTrailingSeparators(workspace)}/${path}`;
|
|
3594
3600
|
};
|
|
3595
|
-
const convertToPick = (
|
|
3596
|
-
const
|
|
3601
|
+
const convertToPick = (workspacePath, uri, path) => {
|
|
3602
|
+
const isWorkspaceRelative = Boolean(workspacePath.uriPrefix && !isAbsolutePath(path) && !hasUriScheme(path) && isSafeRelativePath(path));
|
|
3603
|
+
let displayPath = uri.replaceAll('\\', '/');
|
|
3604
|
+
if (isWorkspaceRelative) {
|
|
3605
|
+
displayPath = `${trimTrailingSeparators(workspacePath.path)}/${path}`;
|
|
3606
|
+
} else if (hasUriScheme(uri)) {
|
|
3607
|
+
displayPath = decodeURIComponent(new URL(uri).pathname);
|
|
3608
|
+
}
|
|
3597
3609
|
const baseName = pathBaseName(displayPath);
|
|
3598
3610
|
const dirName = pathDirName(displayPath);
|
|
3599
|
-
const description = getRelativeDirectory(
|
|
3611
|
+
const description = getRelativeDirectory(workspacePath, uri, dirName, isWorkspaceRelative);
|
|
3600
3612
|
return {
|
|
3601
3613
|
description,
|
|
3602
3614
|
direntType: File,
|
|
@@ -3647,7 +3659,11 @@ const getPicks$b = async searchValue => {
|
|
|
3647
3659
|
});
|
|
3648
3660
|
}
|
|
3649
3661
|
}
|
|
3650
|
-
|
|
3662
|
+
if (files.length === 0) {
|
|
3663
|
+
return [];
|
|
3664
|
+
}
|
|
3665
|
+
const workspacePath = getWorkspaceDisplayPath(workspace);
|
|
3666
|
+
const picks = files.map(path => convertToPick(workspacePath, resolveFileUri(workspace, path, workspacePath), path));
|
|
3651
3667
|
return picks;
|
|
3652
3668
|
};
|
|
3653
3669
|
|