From 8f2a6fe3f51cc8371e1868b975e1057e105e7fcd Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Tue, 12 Feb 2019 17:18:02 +0100 Subject: [PATCH] resources: use posix for non-file URIs --- src/vs/base/common/resources.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/vs/base/common/resources.ts b/src/vs/base/common/resources.ts index 31dd6f4108c..056801ea6a6 100644 --- a/src/vs/base/common/resources.ts +++ b/src/vs/base/common/resources.ts @@ -64,11 +64,11 @@ export function isEqual(first: URI | undefined, second: URI | undefined, ignoreC } export function basename(resource: URI): string { - return paths.basename(resource.path); + return paths.posix.basename(resource.path); } export function extname(resource: URI): string { - return paths.extname(resource.path); + return paths.posix.extname(resource.path); } /** @@ -106,7 +106,7 @@ export function joinPath(resource: URI, ...pathFragment: string[]): URI { if (resource.scheme === Schemas.file) { joinedPath = URI.file(paths.join(fsPath(resource), ...pathFragment)).path; } else { - joinedPath = paths.join(resource.path, ...pathFragment); + joinedPath = paths.posix.join(resource.path, ...pathFragment); } return resource.with({ path: joinedPath @@ -127,7 +127,7 @@ export function normalizePath(resource: URI): URI { if (resource.scheme === Schemas.file) { normalizedPath = URI.file(paths.normalize(fsPath(resource))).path; } else { - normalizedPath = paths.normalize(resource.path); + normalizedPath = paths.posix.normalize(resource.path); } return resource.with({ path: normalizedPath @@ -165,7 +165,10 @@ export function fsPath(uri: URI): string { * Returns true if the URI path is absolute. */ export function isAbsolutePath(resource: URI): boolean { - return paths.isAbsolute(resource.path); + if (resource.scheme === Schemas.file) { + return paths.isAbsolute(fsPath(resource)); + } + return paths.posix.isAbsolute(resource.path); } export function distinctParents(items: T[], resourceAccessor: (item: T) => URI): T[] { -- GitLab