提交 58479e80 编写于 作者: J Johannes Rieken

Revert "Merge pull request #83060 from microsoft/joh/uri-parse"

This reverts commit 30886e2f, reversing
changes made to 525f1e47.
上级 f478d910
......@@ -338,34 +338,6 @@ export function compareIgnoreCase(a: string, b: string): number {
}
}
/**
* [0-9]
*/
export function isAsciiDigit(code: number): boolean {
return code >= CharCode.Digit0 && code <= CharCode.Digit9;
}
/**
* [a-f]
*/
export function isLowerAsciiHex(code: number): boolean {
return code >= CharCode.a && code <= CharCode.f;
}
/**
* [A-F]
*/
export function isUpperAsciiHex(code: number): boolean {
return code >= CharCode.A && code <= CharCode.F;
}
/**
* [0-9a-fA-F]
*/
export function isAsciiHex(code: number): boolean {
return isAsciiDigit(code) || isLowerAsciiHex(code) || isUpperAsciiHex(code);
}
export function isLowerAsciiLetter(code: number): boolean {
return code >= CharCode.a && code <= CharCode.z;
}
......@@ -374,7 +346,7 @@ export function isUpperAsciiLetter(code: number): boolean {
return code >= CharCode.A && code <= CharCode.Z;
}
export function isAsciiLetter(code: number): boolean {
function isAsciiLetter(code: number): boolean {
return isLowerAsciiLetter(code) || isUpperAsciiLetter(code);
}
......
此差异已折叠。
......@@ -149,7 +149,7 @@ export class OpenerService extends Disposable implements IOpenerService {
private async _doOpenExternal(resource: URI, options: OpenOptions | undefined): Promise<boolean> {
const { resolved } = await this.resolveExternalUri(resource, options);
dom.windowOpenNoOpener(resolved.toString());
dom.windowOpenNoOpener(encodeURI(resolved.toString(true)));
return true;
}
......
......@@ -129,11 +129,9 @@ declare namespace monaco {
* Creates a new Uri from a string, e.g. `http://www.msft.com/some/path`,
* `file:///usr/home`, or `scheme:with/path`.
*
* *Note:* When the input lacks a scheme then `file` is used.
*
* @param value A string which represents an Uri (see `Uri#toString`).
*/
static parse(value: string, strict?: boolean): Uri;
static parse(value: string): Uri;
/**
* Creates a new Uri from a file system path, e.g. `c:\my\files`,
* `/usr/home`, or `\\server\share\some\path`.
......
......@@ -1236,8 +1236,8 @@ declare module 'vscode' {
* `file:///usr/home`, or `scheme:with/path`.
*
* *Note* that for a while uris without a `scheme` were accepted. That is not correct
* as all uris should have a scheme. When missing the `file`-scheme is being used unless
* the `strict`-argument is `true` in which case an error is thrown.
* as all uris should have a scheme. To avoid breakage of existing code the optional
* `strict`-argument has been added. We *strongly* advise to use it, e.g. `Uri.parse('my:uri', true)`
*
* @see [Uri.toString](#Uri.toString)
* @param value The string value of an Uri.
......
......@@ -260,7 +260,7 @@ export namespace MarkdownString {
const collectUri = (href: string): string => {
try {
let uri = URI.parse(href, true);
let uri = URI.parse(href);
uri = uri.with({ query: _uriMassage(uri.query, resUris) });
resUris[href] = uri;
} catch (e) {
......
......@@ -36,7 +36,7 @@ suite('Debug - Source', () => {
assert.equal(source.name, 'internalModule.js');
assert.equal(source.inMemory, true);
assert.equal(source.reference, 11);
assert.equal(source.uri.toString(), 'debug:internalModule.js?session=aDebugSessionId&ref=11');
assert.equal(source.uri.toString(), 'debug:internalModule.js?session%3DaDebugSessionId%26ref%3D11');
});
test('get encoded debug data', () => {
......
......@@ -37,16 +37,16 @@ export class WebviewPortMappingManager extends Disposable {
if (tunnel.tunnelLocalPort === mapping.webviewPort) {
return undefined;
}
return uri.with({
return encodeURI(uri.with({
authority: `127.0.0.1:${tunnel.tunnelLocalPort}`,
}).toString();
}).toString(true));
}
}
if (mapping.webviewPort !== mapping.extensionHostPort) {
return uri.with({
return encodeURI(uri.with({
authority: `${requestLocalHostInfo.address}:${mapping.extensionHostPort}`
}).toString();
}).toString(true));
}
}
}
......
......@@ -408,7 +408,7 @@ export class ElectronWindow extends Disposable {
// the main process to prevent window focus issues.
if (this.shouldOpenExternal(resource, options)) {
const { resolved } = await this.openerService.resolveExternalUri(resource, options);
const success = await this.electronService.openExternal(resolved.toString());
const success = await this.electronService.openExternal(encodeURI(resolved.toString(true)));
if (!success && resolved.scheme === Schemas.file) {
// if opening failed, and this is a file, we can still try to reveal it
await this.electronService.showItemInFolder(resolved.fsPath);
......
......@@ -72,17 +72,6 @@ suite('RipgrepTextSearchEngine', () => {
suite('RipgrepParser', () => {
const TEST_FOLDER = URI.file('/foo/bar');
function joinPathExt(uri: URI, path: string): URI {
const result = joinPath(uri, path);
result.toString();
// ^^^^^^^^
// doing this to init the URI._formatted-field because this
// test compares the output of URI.toJSON and because
// calling URI.file (called by RipgrepParser) will also
// initialize URI._formatted
return result;
}
function testParser(inputData: string[], expectedResults: TextSearchResult[]): void {
const testParser = new RipgrepParser(1000, TEST_FOLDER.fsPath);
......@@ -130,7 +119,7 @@ suite('RipgrepTextSearchEngine', () => {
text: 'foobar',
matches: [new Range(0, 3, 0, 6)]
},
uri: joinPathExt(TEST_FOLDER, 'file1.js'),
uri: joinPath(TEST_FOLDER, 'file1.js'),
ranges: [new Range(3, 3, 3, 6)]
}
]);
......@@ -149,7 +138,7 @@ suite('RipgrepTextSearchEngine', () => {
text: 'foobar',
matches: [new Range(0, 3, 0, 6)]
},
uri: joinPathExt(TEST_FOLDER, 'file1.js'),
uri: joinPath(TEST_FOLDER, 'file1.js'),
ranges: [new Range(3, 3, 3, 6)]
},
{
......@@ -157,7 +146,7 @@ suite('RipgrepTextSearchEngine', () => {
text: 'foobar',
matches: [new Range(0, 3, 0, 6)]
},
uri: joinPathExt(TEST_FOLDER, 'app/file2.js'),
uri: joinPath(TEST_FOLDER, 'app/file2.js'),
ranges: [new Range(3, 3, 3, 6)]
},
{
......@@ -165,7 +154,7 @@ suite('RipgrepTextSearchEngine', () => {
text: 'foobar',
matches: [new Range(0, 3, 0, 6)]
},
uri: joinPathExt(TEST_FOLDER, 'app2/file3.js'),
uri: joinPath(TEST_FOLDER, 'app2/file3.js'),
ranges: [new Range(3, 3, 3, 6)]
}
]);
......@@ -194,7 +183,7 @@ suite('RipgrepTextSearchEngine', () => {
text: 'foo bar',
matches: [new Range(0, 3, 0, 7)]
},
uri: joinPathExt(TEST_FOLDER, 'file1.js'),
uri: joinPath(TEST_FOLDER, 'file1.js'),
ranges: [new Range(3, 3, 3, 7)]
},
{
......@@ -202,7 +191,7 @@ suite('RipgrepTextSearchEngine', () => {
text: 'foobar',
matches: [new Range(0, 3, 0, 6)]
},
uri: joinPathExt(TEST_FOLDER, 'app/file2.js'),
uri: joinPath(TEST_FOLDER, 'app/file2.js'),
ranges: [new Range(3, 3, 3, 6)]
},
{
......@@ -210,7 +199,7 @@ suite('RipgrepTextSearchEngine', () => {
text: 'foobar',
matches: [new Range(0, 3, 0, 6)]
},
uri: joinPathExt(TEST_FOLDER, 'app2/file3.js'),
uri: joinPath(TEST_FOLDER, 'app2/file3.js'),
ranges: [new Range(3, 3, 3, 6)]
}
]);
......
......@@ -22,11 +22,13 @@ suite('ExtHostTypeConverter', function () {
data = MarkdownString.from('Hello [link](foo)');
assert.equal(data.value, 'Hello [link](foo)');
assert.equal(size(data.uris!), 0);
assert.equal(size(data.uris!), 1);
assert.ok(!!data.uris!['foo']);
data = MarkdownString.from('Hello [link](www.noscheme.bad)');
assert.equal(data.value, 'Hello [link](www.noscheme.bad)');
assert.equal(size(data.uris!), 0);
assert.equal(size(data.uris!), 1);
assert.ok(!!data.uris!['www.noscheme.bad']);
data = MarkdownString.from('Hello [link](foo:path)');
assert.equal(data.value, 'Hello [link](foo:path)');
......
......@@ -22,8 +22,7 @@ suite('ExtHostTypes', function () {
assert.deepEqual(uri.toJSON(), {
$mid: 1,
scheme: 'file',
path: '/path/test.file',
external: 'file:///path/test.file'
path: '/path/test.file'
});
assert.ok(uri.fsPath);
......@@ -31,7 +30,6 @@ suite('ExtHostTypes', function () {
$mid: 1,
scheme: 'file',
path: '/path/test.file',
external: 'file:///path/test.file',
fsPath: '/path/test.file'.replace(/\//g, isWindows ? '\\' : '/'),
_sep: isWindows ? 1 : undefined,
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册