Fix config injection with custom HTML/CSS

pull/4429/head
Chocobozzz 2021-09-09 09:13:45 +02:00
parent c504295581
commit b4c945f3c7
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 3 additions and 2 deletions

View File

@ -382,8 +382,9 @@ class ClientHtml {
}
private static addServerConfig (htmlStringPage: string, serverConfig: HTMLServerConfig) {
const serverConfigString = JSON.stringify(serverConfig)
const configScriptTag = `<script type="application/javascript">window.PeerTubeServerConfig = '${serverConfigString}'</script>`
// Stringify the JSON object, and then stringify the string object so we can inject it into the HTML
const serverConfigString = JSON.stringify(JSON.stringify(serverConfig))
const configScriptTag = `<script type="application/javascript">window.PeerTubeServerConfig = ${serverConfigString}</script>`
return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.SERVER_CONFIG, configScriptTag)
}