mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-13 23:44:09 +01:00
add _encodeDriveLetterColon to toString #61504
This commit is contained in:
@@ -346,8 +346,8 @@ export class URI implements UriComponents {
|
||||
*
|
||||
* @param skipEncoding Do not encode the result, default is `false`
|
||||
*/
|
||||
public toString(skipEncoding: boolean = false): string {
|
||||
return _asFormatted(this, skipEncoding);
|
||||
public toString(skipEncoding: boolean = false, _encodeDriveLetterColon: boolean = false): string {
|
||||
return _asFormatted(this, skipEncoding, _encodeDriveLetterColon);
|
||||
}
|
||||
|
||||
public toJSON(): object {
|
||||
@@ -398,15 +398,15 @@ class _URI extends URI {
|
||||
return this._fsPath;
|
||||
}
|
||||
|
||||
public toString(skipEncoding: boolean = false): string {
|
||||
if (!skipEncoding) {
|
||||
toString(skipEncoding: boolean = false, _encodeDriveLetterColon: boolean = false): string {
|
||||
if (!skipEncoding && !_encodeDriveLetterColon) {
|
||||
if (!this._formatted) {
|
||||
this._formatted = _asFormatted(this, false);
|
||||
this._formatted = _asFormatted(this, false, _encodeDriveLetterColon);
|
||||
}
|
||||
return this._formatted;
|
||||
} else {
|
||||
// we don't cache that
|
||||
return _asFormatted(this, true);
|
||||
return _asFormatted(this, true, _encodeDriveLetterColon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,7 +575,7 @@ function _makeFsPath(uri: URI): string {
|
||||
/**
|
||||
* Create the external version of a uri
|
||||
*/
|
||||
function _asFormatted(uri: URI, skipEncoding: boolean): string {
|
||||
function _asFormatted(uri: URI, skipEncoding: boolean, encodeDriveLetterColon: boolean): string {
|
||||
|
||||
const encoder = !skipEncoding
|
||||
? encodeURIComponentFast
|
||||
@@ -639,7 +639,7 @@ function _asFormatted(uri: URI, skipEncoding: boolean): string {
|
||||
encodeOffset = 2;
|
||||
}
|
||||
}
|
||||
if (scheme !== 'file' || path.length > encodeOffset && path.charCodeAt(encodeOffset) !== CharCode.Slash) {
|
||||
if (scheme !== 'file' || encodeDriveLetterColon || path.length > encodeOffset && path.charCodeAt(encodeOffset) !== CharCode.Slash) {
|
||||
encodeOffset = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -490,4 +490,13 @@ suite('URI', () => {
|
||||
|
||||
|
||||
});
|
||||
|
||||
test('Storage: workspace identifier changed (URI.toString()) #61504', function () {
|
||||
if (isWindows) {
|
||||
const uri = URI.file('c:\\Users\\bpasero\\Desktop\\Golda\'s Kitchen\\CHANGELOG.md');
|
||||
assert.ok(uri.toString().indexOf('%3A') < 0);
|
||||
assert.ok(uri.toString(false, false).indexOf('%3A') < 0);
|
||||
assert.ok(uri.toString(false, true).indexOf('%3A') > 0);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Vendored
+1
-1
@@ -192,7 +192,7 @@ declare namespace monaco {
|
||||
*
|
||||
* @param skipEncoding Do not encode the result, default is `false`
|
||||
*/
|
||||
toString(skipEncoding?: boolean): string;
|
||||
toString(skipEncoding?: boolean, _encodeDriveLetterColon?: boolean): string;
|
||||
toJSON(): object;
|
||||
static revive(data: UriComponents | any): Uri;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user