#536 - Update relative path

This commit is contained in:
Elio Struyf
2023-03-15 09:02:14 +01:00
parent 623c340f49
commit 92d507364e
2 changed files with 9 additions and 3 deletions
+5 -2
View File
@@ -175,11 +175,14 @@ export class Folders {
let staticFolder = Settings.get<string>(SETTING_CONTENT_STATIC_FOLDER);
if (staticFolder && (staticFolder.includes(WORKSPACE_PLACEHOLDER) || staticFolder === '/')) {
staticFolder = Folders.getAbsFilePath(staticFolder);
staticFolder =
staticFolder === '/'
? Folders.getAbsFilePath('[[workspace]]')
: Folders.getAbsFilePath(staticFolder);
const wsFolder = Folders.getWorkspaceFolder();
if (wsFolder) {
const relativePath = relative(parseWinPath(wsFolder.fsPath), parseWinPath(staticFolder));
return relativePath;
return relativePath === '' ? '/' : relativePath;
}
}
@@ -109,7 +109,10 @@ export const Item: React.FunctionComponent<IItemProps> = ({
relPath = mediaParsed.split(wsFolderParsed).pop();
if (settings.staticFolder && relPath) {
// If the static folder is the root, we can just return the relative path
if (settings.staticFolder === "/") {
return relPath;
} else if (settings.staticFolder && relPath) {
const staticFolderParsed = parseWinPath(settings.staticFolder);
relPath = relPath.split(staticFolderParsed).pop();
}