doesitarm/helpers/check-types.js
2021-11-28 23:31:55 -06:00

19 lines
404 B
JavaScript

// Universal Imports Only
export function isString( maybeString ) {
return (typeof maybeString === 'string' || maybeString instanceof String)
}
export function isValidHttpUrl( string ) {
if ( !isString( string ) ) return false
let url
try {
url = new URL(string)
} catch (_) {
return false
}
return url.protocol === "http:" || url.protocol === "https:"
}