Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
addLink() {
const { value, onChange } = this.props;
const text = getTextContent( slice( value ) );
if ( text && isURL( text ) ) {
onChange( applyFormat( value, { type: name, attributes: { url: text } } ) );
} else if ( text && isEmail( text ) ) {
onChange( applyFormat( value, { type: name, attributes: { url: `mailto:${ text }` } } ) );
} else {
this.setState( { addingLink: true } );
}
}