提交 7ae5c179 编写于 作者: M Martin Aeschlimann

resources: fix tests, normalize/join: use fspath

上级 eeb4873e
......@@ -34,7 +34,7 @@ export function dirname(path: string, separator = nativeSep): string {
return dirname(path.substring(0, path.length - 1));
} else {
let res = path.substring(0, ~idx);
if (isWindows && res.length === 2 && res[res.length - 1] === ':') {
if (isWindows && res[res.length - 1] === ':') {
res += separator; // make sure drive letters end with backslash
}
return res;
......
......@@ -27,10 +27,6 @@ export function basenameOrAuthority(resource: URI): string {
export function isEqualOrParent(resource: URI, candidate: URI, ignoreCase?: boolean): boolean {
if (resource.scheme === candidate.scheme && resource.authority === candidate.authority) {
if (resource.scheme === Schemas.file) {
return paths.isEqualOrParent(resource.path, candidate.path, ignoreCase);
}
return paths.isEqualOrParent(resource.path, candidate.path, ignoreCase, '/');
}
......@@ -82,7 +78,12 @@ export function dirname(resource: URI): URI {
* @returns The resulting URI.
*/
export function joinPath(resource: URI, pathFragment: string): URI {
const joinedPath = paths.join(resource.path || '/', pathFragment);
let joinedPath: string;
if (resource.scheme === Schemas.file) {
joinedPath = URI.file(paths.join(resource.fsPath, pathFragment)).path;
} else {
joinedPath = paths.join(resource.path, pathFragment);
}
return resource.with({
path: joinedPath
});
......@@ -95,7 +96,12 @@ export function joinPath(resource: URI, pathFragment: string): URI {
* @returns The URI with the normalized path.
*/
export function normalizePath(resource: URI): URI {
const normalizedPath = paths.normalize(resource.path, false);
let normalizedPath: string;
if (resource.scheme === Schemas.file) {
normalizedPath = URI.file(paths.normalize(resource.fsPath)).path;
} else {
normalizedPath = paths.normalize(resource.path);
}
return resource.with({
path: normalizedPath
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册