Skip to content

Commit

Permalink
added config support
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Boczkowski committed Dec 10, 2019
1 parent bf98915 commit d82fe49
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions web/client/components/geostory/contents/WebPageWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion web/client/utils/URLUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

0 comments on commit d82fe49

Please sign in to comment.