Skip to content

Commit

Permalink
add test to assert buggy opener behaviour, #140907
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Feb 1, 2022
1 parent 503cd9c commit 01b9db7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/vs/editor/test/browser/services/openerService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,28 @@ suite('OpenerService', function () {
assert.deepStrictEqual(result.resolved.toString(), 'file:///Users/user/folder');
disposable.dispose();
});

test('vscode.open command can\'t open HTTP URL with hash (#) in it [extension development] #140907', async function () {
const openerService = new OpenerService(editorService, NullCommandService);

let actual: string[] = [];

openerService.setDefaultExternalOpener({
async openExternal(href) {
actual.push(href);
return true;
}
});

const href = 'https://gitlab.com/viktomas/test-project/merge_requests/new?merge_request%5Bsource_branch%5D=test-%23-hash';
const uri = URI.parse(href);

assert.ok(await openerService.open(uri));
assert.ok(await openerService.open(href));

assert.deepStrictEqual(actual, [
encodeURI(uri.toString(true)), // BAD, the encoded # (%23) is double encoded to %2523 (% is double encoded)
href // good
]);
});
});

0 comments on commit 01b9db7

Please sign in to comment.