fix(url): use URI-safe base64 encoding in URLs

This commit is contained in:
Mike Cousins
2020-01-10 14:20:36 -05:00
parent 5d4364f6b5
commit 79f1765c9f
4 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -35,5 +35,5 @@ export const fromUrl = data => {
};
export const updateCodeStore = newState => {
codeStore.set(newState);
push('/edit/' + Base64.encode(JSON.stringify(newState)))
};
push('/edit/' + Base64.encodeURI(JSON.stringify(newState)))
};
+1 -1
View File
@@ -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))
}
};
+1 -1
View File
@@ -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' }}]
+3 -3
View File
@@ -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))}`;
});
</script>
@@ -69,4 +69,4 @@ const unsubscribe = codeStore.subscribe( state => {
<a href="{url}" download='' on:click={onDownloadPNG}>
Download PNG
</a>
</div>
</div>