diff --git a/src/react-components/create-object-dialog.js b/src/react-components/create-object-dialog.js index 364bd46b2134fa4c0d97b7d5b5e6342c07dd6e1b..6e7707e00ad4593b6d204e72fd77ca56f7da1b60 100644 --- a/src/react-components/create-object-dialog.js +++ b/src/react-components/create-object-dialog.js @@ -48,19 +48,13 @@ export default class CreateObjectDialog extends Component { } onUrlChange = e => { - let url; - try { - url = new URL(e.target.value); - } catch (_) { - this.setState({ - url: e.target && e.target.value - // Not a valid URL, so don't try to set attributeImage using url.hostname - }); - return; + let attributionImage = this.state.attributionImage; + if (e.target && e.target.value && e.target.validity.valid){ + attributionImage = attributionHostnames[new URL(e.target.value).hostname]; } this.setState({ url: e.target && e.target.value, - attributionImage: e.target && e.target.value && e.target.validity.valid && attributionHostnames[url.hostname] + attributionImage: attributionImage }); };