1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-11 14:20:05 +00:00

Merged branch 'master' into 'issue-62'

This commit is contained in:
Yury Shkoda
2020-09-09 09:14:24 +03:00
11 changed files with 46 additions and 19 deletions

View File

@@ -14,3 +14,4 @@ export * from './serialize'
export * from './splitChunks'
export * from './parseWeboutResponse'
export * from './isUri'
export * from './isUrl'

12
src/utils/isUrl.ts Normal file
View File

@@ -0,0 +1,12 @@
export const isUrl = (url: string): boolean => {
const pattern = new RegExp(
'^(http://|https://)[a-z0-9]+([-.]{1}[a-z0-9]+)*.[a-z]{2,5}(:[0-9]{1,5})?(/.*)?$',
'gi'
)
if (pattern.test(url)) return true
else
throw new Error(
`'${url}' is not a valid url. An example of a valid url is 'http://valid-url.com'.`
)
}