aboutsummaryrefslogtreecommitdiff
path: root/vnext/server/middleware/renderer.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/server/middleware/renderer.js')
-rw-r--r--vnext/server/middleware/renderer.js12
1 files changed, 1 insertions, 11 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>