MCPcopy Index your code
hub / github.com/ThatGuySam/doesitarm / isValidHttpUrl

Function isValidHttpUrl

helpers/check-types.js:26–42  ·  view source on GitHub ↗
( maybeUrl, allowUnsecure = false )

Source from the content-addressed store, hash-verified

24
25
26export function isValidHttpUrl( maybeUrl, allowUnsecure = false ) {
27 if ( !isString( maybeUrl ) ) return false
28
29 let url
30
31 try {
32 url = new URL(maybeUrl)
33 } catch (_) {
34 return false
35 }
36
37 if ( allowUnsecure ) {
38 return url.protocol === "http:" || url.protocol === "https:"
39 }
40
41 return url.protocol === "https:"
42}
43
44export function isValidImageUrl ( maybeUrl ) {
45 if ( !isValidHttpUrl( maybeUrl ) ) return false

Callers 3

getAllUrlsFromSitemapFunction · 0.90
index.test.jsFile · 0.90
isValidImageUrlFunction · 0.85

Calls 1

isStringFunction · 0.85

Tested by

no test coverage detected