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:
Vasu Bhog
2021-10-08 15:24:00 -07:00
committed by GitHub
parent c35cd3e48f
commit faa29945a3
2 changed files with 12 additions and 7 deletions

View File

@@ -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;
}
});
}
/**

View File

@@ -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('<>&()'), '&lt;&gt;&amp;%28%29', 'URL test known escaped characters failed');
assert.strictEqual(escapeUrl('<>&()[]'), '&lt;&gt;&amp;%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 {