Skip to content
Snippets Groups Projects
Commit bc85ab41 authored by johnshaughnessy's avatar johnshaughnessy
Browse files

Simplify setting of attributionImage state

parent a6e729de
No related branches found
No related tags found
No related merge requests found
...@@ -48,19 +48,13 @@ export default class CreateObjectDialog extends Component { ...@@ -48,19 +48,13 @@ export default class CreateObjectDialog extends Component {
} }
onUrlChange = e => { onUrlChange = e => {
let url; let attributionImage = this.state.attributionImage;
try { if (e.target && e.target.value && e.target.validity.valid){
url = new URL(e.target.value); attributionImage = attributionHostnames[new URL(e.target.value).hostname];
} catch (_) {
this.setState({
url: e.target && e.target.value
// Not a valid URL, so don't try to set attributeImage using url.hostname
});
return;
} }
this.setState({ this.setState({
url: e.target && e.target.value, url: e.target && e.target.value,
attributionImage: e.target && e.target.value && e.target.validity.valid && attributionHostnames[url.hostname] attributionImage: attributionImage
}); });
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment