From bd7411e66eb13a0ac42d8df3533dc2cfd82cf633 Mon Sep 17 00:00:00 2001 From: mcbouslog Date: Tue, 11 Dec 2018 12:07:37 -0600 Subject: [PATCH] Add simple checks to external link editor --- .../components/external-links-editor.jsx | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/modules/common/components/external-links-editor.jsx b/src/modules/common/components/external-links-editor.jsx index ca641be4..32077408 100644 --- a/src/modules/common/components/external-links-editor.jsx +++ b/src/modules/common/components/external-links-editor.jsx @@ -25,7 +25,15 @@ export default class ExternalLinksEditor extends React.Component { handleInputChange(index, event) { const urls = this.props.urls; - urls[index][event.target.name] = event.target.value; + const { name, type, value } = event.target; + + let sanitisedValue = value; + if (type === 'url' && value.length > 4) { + const isURL = value.substring(0, 4) === 'http'; + sanitisedValue = isURL ? value : ''; + } + + urls[index][name] = sanitisedValue; this.props.onChange(urls); } @@ -50,18 +58,21 @@ export default class ExternalLinksEditor extends React.Component {