diff --git a/apps/editor/src/__test__/unit/markdown/mdCommand.spec.ts b/apps/editor/src/__test__/unit/markdown/mdCommand.spec.ts index 4fb9bc0f49..aeb81cef87 100644 --- a/apps/editor/src/__test__/unit/markdown/mdCommand.spec.ts +++ b/apps/editor/src/__test__/unit/markdown/mdCommand.spec.ts @@ -292,6 +292,17 @@ describe('addImage command', () => { expect(getTextContent(mde)).toBe('![image](myurl%20%28%29%5B%5D%3C%3E)'); }); + + it('should not decode url which is already encoded', () => { + cmd.exec('addImage', { + altText: 'image', + imageUrl: 'https://firebasestorage.googleapis.com/images%2Fimage.png?alt=media', + }); + + expect(getTextContent(mde)).toBe( + '![image](https://firebasestorage.googleapis.com/images%2Fimage.png?alt=media)' + ); + }); }); describe('addLink command', () => { @@ -318,6 +329,17 @@ describe('addLink command', () => { expect(getTextContent(mde)).toBe('[TOAST UI](myurl%20%28%29%5B%5D%3C%3E)'); }); + + it('should not decode url which is already encoded', () => { + cmd.exec('addLink', { + linkText: 'TOAST UI', + linkUrl: 'https://firebasestorage.googleapis.com/links%2Fimage.png?alt=media', + }); + + expect(getTextContent(mde)).toBe( + '[TOAST UI](https://firebasestorage.googleapis.com/links%2Fimage.png?alt=media)' + ); + }); }); describe('heading command', () => { diff --git a/apps/editor/src/__test__/unit/wysiwyg/wwCommand.spec.ts b/apps/editor/src/__test__/unit/wysiwyg/wwCommand.spec.ts index 73bf45daac..3b6bcb6119 100644 --- a/apps/editor/src/__test__/unit/wysiwyg/wwCommand.spec.ts +++ b/apps/editor/src/__test__/unit/wysiwyg/wwCommand.spec.ts @@ -484,14 +484,14 @@ describe('wysiwyg commands', () => { expect(wwe.getHTML()).toBe('


'); }); - it('should decode attribute and encode wrong markdown charactors', () => { + it('should not decode url which is already encoded', () => { cmd.exec('addImage', { - imageUrl: 'foo %D1%88%D0%B5%D0%BB%D0%BB%D1%8B ()[]<>', - altText: 'foo ()[]<>', + imageUrl: 'https://firebasestorage.googleapis.com/images%2Fimage.png?alt=media', + altText: 'foo', }); expect(wwe.getHTML()).toBe( - '

foo \\(\\)\\[\\]\\<\\>

' + '

foo

' ); }); }); @@ -520,17 +520,6 @@ describe('wysiwyg commands', () => { expect(wwe.getHTML()).toBe('


'); }); - it('should decode attribute and encode wrong markdown charactors', () => { - cmd.exec('addLink', { - linkUrl: 'foo %D1%88%D0%B5%D0%BB%D0%BB%D1%8B ()[]<>', - linkText: 'foo ()[]<>', - }); - - expect(wwe.getHTML()).toBe( - '

foo ()[]<>

' - ); - }); - it('should change link url in selection', () => { cmd.exec('addLink', { linkUrl: '#', @@ -554,6 +543,17 @@ describe('wysiwyg commands', () => { expect(wwe.getHTML()).toBe(expected); }); + + it('should not decode url which is already encoded', () => { + cmd.exec('addLink', { + linkUrl: 'https://firebasestorage.googleapis.com/links%2Fimage.png?alt=media', + linkText: 'foo', + }); + + expect(wwe.getHTML()).toBe( + '

foo

' + ); + }); }); describe(`addLink command with 'linkAttributes' option`, () => {