Use Uri.Utils (#160780)

* Use Uri.Utils

* handle base as folder
This commit is contained in:
Martin Aeschlimann
2022-09-13 17:46:01 +02:00
committed by GitHub
parent b24fefc540
commit 5431050e5f
4 changed files with 9 additions and 85 deletions

View File

@@ -6,7 +6,7 @@
import { DocumentContext } from 'vscode-css-languageservice';
import { endsWith, startsWith } from '../utils/strings';
import { WorkspaceFolder } from 'vscode-languageserver';
import { resolvePath } from '../requests';
import { URI, Utils } from 'vscode-uri';
export function getDocumentContext(documentUri: string, workspaceFolders: WorkspaceFolder[]): DocumentContext {
function getRootFolder(): string | undefined {
@@ -34,8 +34,9 @@ export function getDocumentContext(documentUri: string, workspaceFolders: Worksp
return folderUri + ref.substr(1);
}
}
base = base.substr(0, base.lastIndexOf('/') + 1);
return resolvePath(base, ref);
const baseUri = URI.parse(base);
const baseUriDir = baseUri.path.endsWith('/') ? baseUri : Utils.dirname(baseUri);
return Utils.resolvePath(baseUriDir, ref).toString(true);
},
};
}