From f8a349915660bac9cd61375b708d68f403a6a42f Mon Sep 17 00:00:00 2001 From: Mike Fix Date: Mon, 6 Aug 2018 15:01:09 -0700 Subject: [PATCH] safari bug fixes --- components/Editor.js | 2 +- lib/routing.js | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/components/Editor.js b/components/Editor.js index 228acaa..50efd90 100644 --- a/components/Editor.js +++ b/components/Editor.js @@ -81,7 +81,7 @@ class Editor extends React.Component { if ( navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1 && - format === 'png' + format !== 'svg' ) { const encodedState = serializeState(this.state) return api.image(encodedState) diff --git a/lib/routing.js b/lib/routing.js index e71605c..73665fd 100644 --- a/lib/routing.js +++ b/lib/routing.js @@ -50,12 +50,11 @@ const reverseMappings = mappings.map(mapping => ) export const serializeState = state => { - const stateString = JSON.stringify(state) + const stateString = encodeURIComponent(JSON.stringify(state)) - return encodeURIComponent( - typeof window !== 'undefined' - ? btoa(stateString) - : Buffer.from(stateString).toString('base64') + return encodeURIComponent(typeof window !== 'undefined' + ? btoa(stateString) + : Buffer.from(stateString).toString('base64') ) }