Created
November 26, 2021 05:18
-
-
Save nguyentuan1696/972b71fc0716089dd3dc5f3a69e13ded to your computer and use it in GitHub Desktop.
Check is external url
This file contains hidden or 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
export function hasProtocol(url) { | |
return /^(\w*:|\/\/)/.test(url) === true | |
} | |
export default function isInternalUrl(url) { | |
return typeof url !== 'undefined' && !hasProtocol(url) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment