Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private handleSubmit = (e: Event) => {
e.preventDefault()
const { url } = this.state
// return when required fields are empty, and url value is no url
// Can't use browser validation cause we are in a form within a form
if (!url) {
this.setState({ hasError: true })
return
}
if (url && !url.includes('ipfs://') && !isUrl(url)) {
this.setState({ noUrl: true })
return
}
this.props.addFile(url)
}
public constructor(private readonly host: string) {
if (!isUrl(host)) {
throw new Error(`${host} is not a valid URL.`);
}
}
isUrl: (input: string) => {
return isUrl(input);
},