woocommerce/plugins/woocommerce-docs/client/util/url.ts

9 lines
203 B
TypeScript
Raw Normal View History

export const isURL = ( urlString: string ): boolean => {
try {
const url = new URL( urlString );
return url.protocol === 'http:' || url.protocol === 'https:';
} catch ( e ) {
return false;
}
};