mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 01:25:37 -05:00
Fix quoted link failures by removing quotes from unescaped paths, rather than just the escaped paths. (#17419)
This commit is contained in:
@@ -45,7 +45,7 @@ export function unquoteText(quotedText: string): string {
|
||||
let doubleQuotesRegex = /^[\"\'](.*)[\"\']$/;
|
||||
let matches = doubleQuotesRegex.exec(quotedText);
|
||||
if (matches && matches[1]) {
|
||||
quotedText = matches[1];
|
||||
return matches[1];
|
||||
}
|
||||
return quotedText;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,8 @@ export class LinkCalloutDialog extends Modal {
|
||||
public insert(): void {
|
||||
this.hide('ok');
|
||||
let escapedLabel = escapeLabel(this._linkTextInputBox.value);
|
||||
let escapedUrl = escapeUrl(unquoteText(this._linkUrlInputBox.value));
|
||||
let unquotedUrl = unquoteText(this._linkUrlInputBox.value);
|
||||
let escapedUrl = escapeUrl(unquotedUrl);
|
||||
|
||||
if (this._previouslySelectedRange) {
|
||||
// Reset selection to previous state before callout was open
|
||||
@@ -169,7 +170,7 @@ export class LinkCalloutDialog extends Modal {
|
||||
this._selectionComplete.resolve({
|
||||
insertEscapedMarkdown: `[${escapedLabel}](${escapedUrl})`,
|
||||
insertUnescapedLinkLabel: this._linkTextInputBox.value,
|
||||
insertUnescapedLinkUrl: this._linkUrlInputBox.value
|
||||
insertUnescapedLinkUrl: unquotedUrl
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,4 +146,26 @@ suite('Link Callout Dialog', function (): void {
|
||||
assert.strictEqual(result.insertEscapedMarkdown, `[${defaultLabel}](${sampleUrl})`, 'Markdown not returned correctly');
|
||||
});
|
||||
|
||||
test('Should handle quoted URLs properly', async function (): Promise<void> {
|
||||
const defaultLabel = 'defaultLabel';
|
||||
const unquotedUrl = 'C:/Test/Test.ipynb';
|
||||
const quotedUrl = `"${unquotedUrl}"`;
|
||||
let linkCalloutDialog = new LinkCalloutDialog('Title', 'below', defaultDialogProperties, defaultLabel, '',
|
||||
undefined, themeService, layoutService, telemetryService, contextKeyService, undefined, undefined, undefined);
|
||||
linkCalloutDialog.render();
|
||||
|
||||
let deferred = new Deferred<ILinkCalloutDialogOptions>();
|
||||
// When I first open the callout dialog
|
||||
linkCalloutDialog.open().then(value => {
|
||||
deferred.resolve(value);
|
||||
});
|
||||
linkCalloutDialog.url = quotedUrl;
|
||||
|
||||
// And insert the dialog
|
||||
linkCalloutDialog.insert();
|
||||
let result = await deferred.promise;
|
||||
assert.strictEqual(result.insertUnescapedLinkLabel, defaultLabel, 'Label not returned correctly');
|
||||
assert.strictEqual(result.insertUnescapedLinkUrl, unquotedUrl, 'URL not unquoted correctly');
|
||||
assert.strictEqual(result.insertEscapedMarkdown, `[${defaultLabel}](${unquotedUrl})`, 'Markdown not unquoted correctly');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user