mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
Git - Handle repository paths with a trailing \ character (#159461)
* Fix another edge case with Windows path that contains a trailing \ character * Pull request feedback
This commit is contained in:
@@ -505,13 +505,6 @@ export class Git {
|
||||
|
||||
return path.normalize(pathUri.fsPath);
|
||||
}
|
||||
|
||||
// On Windows, there are cases in which the normalized path for a mapped folder contains a trailing `\`
|
||||
// character (ex: \\server\folder\) due to the implementation of `path.normalize()`. This behaviour is
|
||||
// by design as documented in https://github.com/nodejs/node/issues/1765.
|
||||
if (repoUri.authority.length !== 0) {
|
||||
return repoPath.replace(/\\$/, '');
|
||||
}
|
||||
}
|
||||
|
||||
return repoPath;
|
||||
|
||||
@@ -314,6 +314,13 @@ export function pathEquals(a: string, b: string): boolean {
|
||||
* casing.
|
||||
*/
|
||||
export function relativePath(from: string, to: string): string {
|
||||
// On Windows, there are cases in which `from` is a path that contains a trailing `\` character
|
||||
// (ex: C:\, \\server\folder\) due to the implementation of `path.normalize()`. This behavior is
|
||||
// by design as documented in https://github.com/nodejs/node/issues/1765.
|
||||
if (isWindows) {
|
||||
from = from.replace(/\\$/, '');
|
||||
}
|
||||
|
||||
if (isDescendant(from, to) && from.length < to.length) {
|
||||
return to.substring(from.length + 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user