Skip to content
GitLab
Next
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Commits on Source (2)
(fix) use regexp with g flag in replace method
· 5ddd3726
Juan Manuel Solaro
authored
Dec 06, 2019
5ddd3726
Merge branch 'fix-html-replace-in-blog-view-html' into 'release/3.12.1'
· 77bbd113
Brian Hatchet
authored
Dec 09, 2019
Fix html replace in BlogViewHTML See merge request
!445
77bbd113
Hide whitespace changes
Inline
Side-by-side
src/blogs/BlogViewHTML.js
View file @
77bbd113
...
...
@@ -153,9 +153,12 @@ export default class BlogViewHTML extends Component {
}
if
(
html
.
indexOf
(
'
<iframe
'
)
>=
0
)
{
html
=
html
.
replace
(
'
<iframe
'
,
'
<div class="iframewrapper"><iframe
'
);
html
=
html
.
replace
(
'
</iframe>
'
,
'
</iframe></div>
'
);
html
=
html
.
replace
(
'
src="//
'
,
'
src="https://
'
);
const
iframeOpen
=
new
RegExp
(
/
\<
iframe/g
);
const
iframeClose
=
new
RegExp
(
/
\<\/
iframe
\>
/g
);
const
badSrc
=
new
RegExp
(
/src=
\"\/\/
/g
);
html
=
html
.
replace
(
iframeOpen
,
'
<div class="iframewrapper"><iframe
'
);
html
=
html
.
replace
(
iframeClose
,
'
</iframe></div>
'
);
html
=
html
.
replace
(
badSrc
,
'
src="https://
'
);
}
return
`<!DOCTYPE html><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
...
...