From 79f1765c9f40cda1e6e4736beddd030efe6ebfd6 Mon Sep 17 00:00:00 2001 From: Mike Cousins Date: Fri, 10 Jan 2020 14:20:36 -0500 Subject: [PATCH] fix(url): use URI-safe base64 encoding in URLs --- src/code-store.js | 4 ++-- src/components/Config.svelte | 2 +- src/components/Editor.svelte | 2 +- src/components/Links.svelte | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/code-store.js b/src/code-store.js index c6e6ec1f47..5467901d4a 100644 --- a/src/code-store.js +++ b/src/code-store.js @@ -35,5 +35,5 @@ export const fromUrl = data => { }; export const updateCodeStore = newState => { codeStore.set(newState); - push('/edit/' + Base64.encode(JSON.stringify(newState))) -}; \ No newline at end of file + push('/edit/' + Base64.encodeURI(JSON.stringify(newState))) +}; diff --git a/src/components/Config.svelte b/src/components/Config.svelte index 57572d5b4b..dc36da2f1e 100644 --- a/src/components/Config.svelte +++ b/src/components/Config.svelte @@ -38,7 +38,7 @@ const handleConfUpdate = conf => { console.log('Error in parsed', e); configErrorStore.set(e); const str = JSON.stringify({ code, mermaid: oldConf }); - push('/edit/' + Base64.encode(str)) + push('/edit/' + Base64.encodeURI(str)) } }; diff --git a/src/components/Editor.svelte b/src/components/Editor.svelte index 56af40bb16..ec1b453031 100644 --- a/src/components/Editor.svelte +++ b/src/components/Editor.svelte @@ -36,7 +36,7 @@ const handleCodeUpdate = code => { codeErrorStore.set(e); console.log('Error in parsed', e.hash); const str = JSON.stringify({ code: code, mermaid: conf }); - push('/edit/' + Base64.encode(str)) + push('/edit/' + Base64.encodeURI(str)) const l = e.hash.line; decArr.push(edit.deltaDecorations([], [ { range: new monaco.Range(e.hash.loc.first_line,e.hash.loc.last_line,e.hash.loc.first_column,e.hash.loc.last_column), options: { inlineClassName: 'myInlineDecoration' }}] diff --git a/src/components/Links.svelte b/src/components/Links.svelte index 905e96c1f9..a64a4ae2fa 100644 --- a/src/components/Links.svelte +++ b/src/components/Links.svelte @@ -53,8 +53,8 @@ export const onDownloadSVG = event => { let url = '/mermaid-live-editor/#/view'; let iUrl; const unsubscribe = codeStore.subscribe( state => { - url = '/mermaid-live-editor/#/view/' + Base64.encode(JSON.stringify(state)); - iUrl = `https://mermaid.ink/img/${Base64.encode(JSON.stringify(state))}`; + url = '/mermaid-live-editor/#/view/' + Base64.encodeURI(JSON.stringify(state)); + iUrl = `https://mermaid.ink/img/${Base64.encodeURI(JSON.stringify(state))}`; }); @@ -69,4 +69,4 @@ const unsubscribe = codeStore.subscribe( state => { Download PNG - \ No newline at end of file +