mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-07 01:25:38 -05:00
Fixes Encoding / Decoding issues with Notebook Linking (#17304)
* fixes encoding / decoding issues with %20 files * fix windows test * address PR comments and absolute path setting
This commit is contained in:
@@ -129,12 +129,12 @@ suite('HTML Markdown Converter', function (): void {
|
||||
});
|
||||
|
||||
test('Should transform <a> tag', () => {
|
||||
configurationService.updateValue('notebook.keepAbsolutePath', false, ConfigurationTarget.USER);
|
||||
configurationService.updateValue('notebook.useAbsoluteFilePaths', false, ConfigurationTarget.USER);
|
||||
htmlString = '<a href="/tmp/stuff.png">stuff</a>';
|
||||
assert.strictEqual(htmlMarkdownConverter.convert(htmlString), `[stuff](.${path.sep}stuff.png)`, 'Basic link test failed');
|
||||
htmlString = '<a href="/tmp/stuff.png"</a>';
|
||||
assert.strictEqual(htmlMarkdownConverter.convert(htmlString), `[](.${path.sep}stuff.png)`, 'Basic link test no label failed');
|
||||
htmlString = '<a href="/tmp/my stuff.png"</a>';
|
||||
htmlString = '<a href="/tmp/my stuff.png"></a>';
|
||||
assert.strictEqual(htmlMarkdownConverter.convert(htmlString), `[](.${path.sep}my%20stuff.png)`, 'Basic link test no label space filename failed');
|
||||
htmlString = '<a href="/stuff.png">stuff</a>';
|
||||
assert.strictEqual(htmlMarkdownConverter.convert(htmlString), `[stuff](..${path.sep}stuff.png)`, 'Basic link test above folder failed');
|
||||
|
||||
@@ -75,8 +75,7 @@ suite('Noteboook Link Handler', function (): void {
|
||||
});
|
||||
|
||||
test('Should return absolute links with keep absolute path setting', () => {
|
||||
// let basePath = process.cwd();
|
||||
configurationService.updateValue('notebook.keepAbsolutePath', true, ConfigurationTarget.USER);
|
||||
configurationService.updateValue('notebook.useAbsoluteFilePaths', true, ConfigurationTarget.USER);
|
||||
let result = new NotebookLinkHandler(notebookUri, 'https://www.microsoft.com/images/msft.png', configurationService);
|
||||
assert.strictEqual(result.getLinkUrl(), `https://www.microsoft.com/images/msft.png`, 'HTTPS link failed to resolve');
|
||||
|
||||
@@ -123,6 +122,6 @@ suite('Noteboook Link Handler', function (): void {
|
||||
assert.strictEqual(result.getLinkUrl(), `.${path.sep}my%20stuff.png`, 'Basic link test with space filename failed');
|
||||
|
||||
result = new NotebookLinkHandler(notebookUri, Object.assign(document.createElement('a'), { href: '/tmp/my%20stuff.png' }), configurationService);
|
||||
assert.strictEqual(result.getLinkUrl(), `.${path.sep}my%20stuff.png`, 'Basic link test with space filename failed');
|
||||
assert.strictEqual(result.getLinkUrl(), `.${path.sep}my%2520stuff.png`, 'Basic link test with %20 filename failed');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,16 +50,16 @@ suite('NotebookMarkdownRenderer', () => {
|
||||
|
||||
test('link from local file path', () => {
|
||||
let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: `[Link to File Path](someFileurl)`, isTrusted: true });
|
||||
assert.strictEqual(result.innerHTML, `<p><a href="someFileurl" data-href="someFileurl" title="someFileurl" is-absolute="false">Link to File Path</a></p>`);
|
||||
assert.strictEqual(result.innerHTML, `<p><a href="someFileurl" data-href="someFileurl" title="someFileurl" is-markdown="true" is-absolute="false">Link to File Path</a></p>`);
|
||||
});
|
||||
|
||||
test('link from relative file path', () => {
|
||||
notebookMarkdownRenderer.setNotebookURI(URI.parse(`foo/temp/file1.txt`));
|
||||
let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: `[Link to relative path](../test/build/someimageurl)`, isTrusted: true });
|
||||
if (process.platform === 'win32') {
|
||||
assert.strictEqual(result.innerHTML, `<p><a href="\\foo\\test\\build\\someimageurl" data-href="\\foo\\test\\build\\someimageurl" title="\\foo\\test\\build\\someimageurl" is-absolute="false">Link to relative path</a></p>`);
|
||||
assert.strictEqual(result.innerHTML, `<p><a href="\\foo\\test\\build\\someimageurl" data-href="\\foo\\test\\build\\someimageurl" title="\\foo\\test\\build\\someimageurl" is-markdown="true" is-absolute="false">Link to relative path</a></p>`);
|
||||
} else {
|
||||
assert.strictEqual(result.innerHTML, `<p><a href="/foo/test/build/someimageurl" data-href="/foo/test/build/someimageurl" title="/foo/test/build/someimageurl" is-absolute="false">Link to relative path</a></p>`);
|
||||
assert.strictEqual(result.innerHTML, `<p><a href="/foo/test/build/someimageurl" data-href="/foo/test/build/someimageurl" title="/foo/test/build/someimageurl" is-markdown="true" is-absolute="false">Link to relative path</a></p>`);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -72,17 +72,17 @@ suite('NotebookMarkdownRenderer', () => {
|
||||
|
||||
test('email in markdown format renders properly', () => {
|
||||
let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: `[test@email.com](mailto:test@email.com)`, isTrusted: true });
|
||||
assert.strictEqual(result.innerHTML, `<p><a href="mailto:test@email.com" data-href="mailto:test@email.com" title="mailto:test@email.com" is-absolute="false">test@email.com</a></p>`);
|
||||
assert.strictEqual(result.innerHTML, `<p><a href="mailto:test@email.com" data-href="mailto:test@email.com" title="mailto:test@email.com" is-markdown="true" is-absolute="false">test@email.com</a></p>`);
|
||||
});
|
||||
|
||||
test('email inserted directly renders properly', () => {
|
||||
let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: `test@email.com`, isTrusted: true });
|
||||
assert.strictEqual(result.innerHTML, `<p><a href="mailto:test@email.com" data-href="mailto:test@email.com" title="mailto:test@email.com" is-absolute="false">test@email.com</a></p>`);
|
||||
assert.strictEqual(result.innerHTML, `<p><a href="mailto:test@email.com" data-href="mailto:test@email.com" title="mailto:test@email.com" is-markdown="true" is-absolute="false">test@email.com</a></p>`);
|
||||
});
|
||||
|
||||
test('link to https with query parameters', () => {
|
||||
let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: `[test](https://www.test.com?test=&test2=)`, isTrusted: true });
|
||||
assert.strictEqual(result.innerHTML, `<p><a href="https://www.test.com?test=&test2=" data-href="https://www.test.com?test=&test2=" title="https://www.test.com?test=&test2=" is-absolute="false">test</a></p>`);
|
||||
assert.strictEqual(result.innerHTML, `<p><a href="https://www.test.com?test=&test2=" data-href="https://www.test.com?test=&test2=" title="https://www.test.com?test=&test2=" is-markdown="true" is-absolute="false">test</a></p>`);
|
||||
});
|
||||
|
||||
test('cell attachment image', () => {
|
||||
|
||||
Reference in New Issue
Block a user