mirror of
https://github.com/sasjs/adapter.git
synced 2026-01-07 20:40:05 +00:00
18 lines
335 B
TypeScript
18 lines
335 B
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
|
|
}
|