Skip to content

Commit

Permalink
Handle unwanted commas
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnstn committed Apr 11, 2023
1 parent 3a798fb commit fc904d2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/components/src/sandbox/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,19 @@ const Sandbox = forwardRef( function Sandbox(
// we can use this in the future to inject custom styles or scripts.
// Scripts go into the body rather than the head, to support embedded content such as Instagram
// that expect the scripts to be part of the body.

// Avoid comma issues with props.viewportProps.
const addViewportProps = viewportProps
.trim()
.replace( /(^[^,]) /, ', $1' );

const htmlDoc = (
<html lang={ lang }>
<head>
<title>{ title }</title>
<meta
name="viewport"
content={ `width=device-width, initial-scale=1, ${ viewportProps }` }
content={ `width=device-width, initial-scale=1 ${ addViewportProps }` }
></meta>
<style dangerouslySetInnerHTML={ { __html: style } } />
{ styles.map( ( rules, i ) => (
Expand Down

0 comments on commit fc904d2

Please sign in to comment.