mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 17:22:55 -05:00
Fix Link Callout Dialog consistency in split/md (#17313)
* fix consistency with space and %20 files in split/md * add a test
This commit is contained in:
@@ -26,13 +26,15 @@ export function escapeLabel(unescapedLabel: string): string {
|
||||
*/
|
||||
export function escapeUrl(unescapedUrl: string): string {
|
||||
let firstEscape = strings.escape(unescapedUrl);
|
||||
return firstEscape.replace(/[()]/g, function (match) {
|
||||
switch (match) {
|
||||
case '(': return '%28';
|
||||
case ')': return '%29';
|
||||
default: return match;
|
||||
}
|
||||
});
|
||||
return firstEscape.replace(/%20/g, '%2520')
|
||||
.replace(/\s/g, '%20')
|
||||
.replace(/[()]/g, function (match) {
|
||||
switch (match) {
|
||||
case '(': return '%28';
|
||||
case ')': return '%29';
|
||||
default: return match;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -105,6 +105,9 @@ suite('Link Callout Dialog', function (): void {
|
||||
assert.strictEqual(escapeUrl('Test()URL'), 'Test%28%29URL', 'URL test square brackets failed');
|
||||
assert.strictEqual(escapeUrl('<>&()'), '<>&%28%29', 'URL test known escaped characters failed');
|
||||
assert.strictEqual(escapeUrl('<>&()[]'), '<>&%28%29[]', 'URL test all escaped characters failed');
|
||||
assert.strictEqual(escapeUrl('TEST URL'), 'TEST%20URL', 'URL with spaces failed');
|
||||
assert.strictEqual(escapeUrl('TEST%20URL'), 'TEST%2520URL', 'URL with %20 failed');
|
||||
assert.strictEqual(escapeUrl('TEST %20 URL'), 'TEST%20%2520%20URL', 'URL with %20 and spaces failed');
|
||||
});
|
||||
|
||||
test('Unquote text', function (): void {
|
||||
|
||||
Reference in New Issue
Block a user