Last active
August 31, 2018 10:31
-
-
Save pujansrt/ca9cc35cb0feafdadcaeee430916b66a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async getUrlInfo(url: string) { | |
const reg = new RegExp("https?://([a-z0-9]+[.])*.?ea[.]com"); | |
const reg2 = new RegExp("^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w\\.-]+)+[\\w\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]+$"); | |
async function reachability() { | |
const responseReachable: any = await fetch(url, {method: 'HEAD'}).catch(() => false); | |
return responseReachable.status === 200; | |
} | |
return { | |
valid: reg2.test(url), | |
internal: reg.test(url), | |
reachable: reachability() | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment