aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vnext/server/middleware/renderer.js12
-rw-r--r--vnext/src/index.js12
2 files changed, 2 insertions, 22 deletions
diff --git a/vnext/server/middleware/renderer.js b/vnext/server/middleware/renderer.js
index e7e0324e..ae2600a7 100644
--- a/vnext/server/middleware/renderer.js
+++ b/vnext/server/middleware/renderer.js
@@ -12,16 +12,6 @@ import { VisitorProvider } from '../../src/ui/VisitorContext'
import path from 'path'
import fs from 'fs'
-// convert a Unicode string to a string in which
-// each 16-bit unit occupies only one byte
-function toBinary(string) {
- const codeUnits = new Uint16Array(string.length)
- for (let i = 0; i < codeUnits.length; i++) {
- codeUnits[i] = string.charCodeAt(i)
- }
- return Buffer.from(String.fromCharCode(...new Uint8Array(codeUnits.buffer))).toString('base64')
-}
-
const STATIC_ROOT = config.get('service.static_root') || path.resolve(__dirname, 'public')
const serverRenderer = async (req, res) => {
@@ -47,7 +37,7 @@ const serverRenderer = async (req, res) => {
const marker = '<div id="app">'
const data = htmlData.split(marker)
- const propsData = `<script>window.__PROPS__="${toBinary(JSON.stringify(props))}";</script>${marker}`
+ const propsData = `<script>window.__PROPS__="${btoa(unescape(encodeURIComponent(JSON.stringify(props))))}";</script>${marker}`
let didError = false
const { pipe } = ReactDOMServer.renderToPipeableStream(
<VisitorProvider>
diff --git a/vnext/src/index.js b/vnext/src/index.js
index 5ab543c4..0c936257 100644
--- a/vnext/src/index.js
+++ b/vnext/src/index.js
@@ -16,17 +16,7 @@ import { CookiesProvider } from 'react-cookie'
import { VisitorProvider } from './ui/VisitorContext'
const Juick = lazy(() => import('./App'))
-
-function fromBinary(encoded) {
- const binary = window.atob(encoded)
- const bytes = new Uint8Array(binary.length)
- for (let i = 0; i < bytes.length; i++) {
- bytes[i] = binary.charCodeAt(i)
- }
- return String.fromCharCode(...new Uint16Array(bytes.buffer))
-}
-
-const props = window.__PROPS__ ? JSON.parse(fromBinary(window.__PROPS__)) : {}
+const props = window.__PROPS__ ? JSON.parse(decodeURIComponent(escape(atob(window.__PROPS__)))) : {}
const JuickApp = () => (
<StrictMode>