提交 d86ae3ee 编写于 作者: J Johannes Rieken

Revert "fix #58985"

This reverts commit 258f8dc8.
上级 68229da5
......@@ -466,11 +466,11 @@ const encodeTable: { [ch: number]: string } = {
[CharCode.Space]: '%20',
};
function encodeURIComponentFast(uriComponent: string, allowSlash: boolean, firstPos: number = 0): string {
let res: string | undefined = undefined;
function encodeURIComponentFast(uriComponent: string, allowSlash: boolean): string {
let res: string = undefined;
let nativeEncodePos = -1;
for (let pos = firstPos; pos < uriComponent.length; pos++) {
for (let pos = 0; pos < uriComponent.length; pos++) {
let code = uriComponent.charCodeAt(pos);
// unreserved characters: https://tools.ietf.org/html/rfc3986#section-2.3
......@@ -620,31 +620,19 @@ function _asFormatted(uri: URI, skipEncoding: boolean): string {
}
if (path) {
// lower-case windows drive letters in /C:/fff or C:/fff
let encodeOffset = 0;
if (path.length >= 3 && path.charCodeAt(0) === CharCode.Slash && path.charCodeAt(2) === CharCode.Colon) {
let code = path.charCodeAt(1);
if (code >= CharCode.A && code <= CharCode.Z) {
path = `/${String.fromCharCode(code + 32)}:${path.substr(3)}`; // "/c:".length === 3
encodeOffset = 3;
} else if (code >= CharCode.a && code <= CharCode.z) {
encodeOffset = 3;
}
} else if (path.length >= 2 && path.charCodeAt(1) === CharCode.Colon) {
let code = path.charCodeAt(0);
if (code >= CharCode.A && code <= CharCode.Z) {
path = `${String.fromCharCode(code + 32)}:${path.substr(2)}`; // "/c:".length === 3
encodeOffset = 2;
} else if (code >= CharCode.a && code <= CharCode.z) {
encodeOffset = 2;
}
}
if (scheme !== 'file' || path.length > encodeOffset && path.charCodeAt(encodeOffset) !== CharCode.Slash) {
encodeOffset = 0;
}
// encode the rest of the path
res += encoder(path, true, encodeOffset);
res += encoder(path, true);
}
if (query) {
res += '?';
......
......@@ -10,19 +10,20 @@ import { isWindows } from 'vs/base/common/platform';
suite('URI', () => {
test('file#toString', () => {
assert.equal(URI.file('c:/win/path').toString(), 'file:///c:/win/path');
assert.equal(URI.file('C:/win/path').toString(), 'file:///c:/win/path');
assert.equal(URI.file('c:/win/path/').toString(), 'file:///c:/win/path/');
assert.equal(URI.file('/c:/win/path').toString(), 'file:///c:/win/path');
assert.equal(URI.file('c:/win/path').toString(), 'file:///c%3A/win/path');
assert.equal(URI.file('C:/win/path').toString(), 'file:///c%3A/win/path');
assert.equal(URI.file('c:/win/path/').toString(), 'file:///c%3A/win/path/');
assert.equal(URI.file('/c:/win/path').toString(), 'file:///c%3A/win/path');
});
test('URI.file (win-special)', () => {
if (isWindows) {
assert.equal(URI.file('c:\\win\\path').toString(), 'file:///c:/win/path');
assert.equal(URI.file('c:\\win/path').toString(), 'file:///c:/win/path');
assert.equal(URI.file('c:\\win\\path').toString(), 'file:///c%3A/win/path');
assert.equal(URI.file('c:\\win/path').toString(), 'file:///c%3A/win/path');
} else {
assert.equal(URI.file('c:\\win\\path').toString(), 'file:///c%3A%5Cwin%5Cpath');
assert.equal(URI.file('c:\\win/path').toString(), 'file:///c%3A%5Cwin/path');
}
});
......@@ -239,7 +240,7 @@ suite('URI', () => {
if (isWindows) {
var value = URI.file('c:\\test\\drive');
assert.equal(value.path, '/c:/test/drive');
assert.equal(value.toString(), 'file:///c:/test/drive');
assert.equal(value.toString(), 'file:///c%3A/test/drive');
value = URI.file('\\\\shäres\\path\\c#\\plugin.json');
assert.equal(value.scheme, 'file');
......@@ -259,15 +260,15 @@ suite('URI', () => {
value = URI.file('c:\\test with %\\path');
assert.equal(value.path, '/c:/test with %/path');
assert.equal(value.toString(), 'file:///c:/test%20with%20%25/path');
assert.equal(value.toString(), 'file:///c%3A/test%20with%20%25/path');
value = URI.file('c:\\test with %25\\path');
assert.equal(value.path, '/c:/test with %25/path');
assert.equal(value.toString(), 'file:///c:/test%20with%20%2525/path');
assert.equal(value.toString(), 'file:///c%3A/test%20with%20%2525/path');
value = URI.file('c:\\test with %25\\c#code');
assert.equal(value.path, '/c:/test with %25/c#code');
assert.equal(value.toString(), 'file:///c:/test%20with%20%2525/c%23code');
assert.equal(value.toString(), 'file:///c%3A/test%20with%20%2525/c%23code');
value = URI.file('\\\\shares');
assert.equal(value.scheme, 'file');
......
......@@ -51,8 +51,8 @@ suite('Search - Viewlet', () => {
let lineMatch = fileMatch.matches()[0];
assert.equal(ds.getId(null, result), 'root');
assert.equal(ds.getId(null, fileMatch), 'file:///c:/foo');
assert.equal(ds.getId(null, lineMatch), 'file:///c:/foo>[2,1 -> 2,2]b');
assert.equal(ds.getId(null, fileMatch), 'file:///c%3A/foo');
assert.equal(ds.getId(null, lineMatch), 'file:///c%3A/foo>[2,1 -> 2,2]b');
assert(!ds.hasChildren(null, 'foo'));
assert(ds.hasChildren(null, result));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册