@sasjs/adapter
Version:
JavaScript adapter for SAS
18 lines (14 loc) • 335 B
text/typescript
/**
* Checks if string is in URL format.
* @param str - string to check.
*/
export const isUrl = (str: string): boolean => {
const supportedProtocols = ['http:', 'https:']
try {
const url = new URL(str)
if (!supportedProtocols.includes(url.protocol)) return false
} catch (_) {
return false
}
return true
}