diff --git a/web/client/components/geostory/contents/WebPageWrapper.jsx b/web/client/components/geostory/contents/WebPageWrapper.jsx index b692038e90..5c1c600ded 100644 --- a/web/client/components/geostory/contents/WebPageWrapper.jsx +++ b/web/client/components/geostory/contents/WebPageWrapper.jsx @@ -17,6 +17,7 @@ import PropTypes from 'prop-types'; import WebPage from './WebPage'; import { compose, withHandlers } from 'recompose'; import { isValidURL } from '../../../utils/URLUtils'; +import { getConfigProp } from '../../../utils/ConfigUtils'; export class WebPageWrapper extends React.PureComponent { static propTypes = { @@ -81,8 +82,8 @@ export class WebPageWrapper extends React.PureComponent { save = () => { const { url } = this.state; - const error = !isValidURL(url); - this.setState({ error: !isValidURL(url) }); + const error = !isValidURL(url, getConfigProp("GeoStoryValidIframeURLRegex")); + this.setState({ error }); if (!error) { this.props.onChange(url); } diff --git a/web/client/utils/URLUtils.js b/web/client/utils/URLUtils.js index 479e84f4bf..3b12ce9bd1 100644 --- a/web/client/utils/URLUtils.js +++ b/web/client/utils/URLUtils.js @@ -77,5 +77,6 @@ export const isSameUrl = (u1, u2) => { * @param {RegExp} regexp - optional custom regexp */ export const isValidURL = (url, regexp = /^(http(s{0,1}):\/\/)+?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/) => { - return regexp.test(url); + const regex = new RegExp(regexp); + return regex.test(url); };