Last active
April 23, 2021 18:57
-
-
Save eligrey/574682 to your computer and use it in GitHub Desktop.
origin regex for javascript
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
// Origin regex | |
const origin = /^[\w-]+:\/*\[?[\p{L}\d\\.:_-]+\]?(?::\d*)?/u; | |
"http://[::1]:234/foo?bar#baz".match(origin)[0] === "http://[::1]:234"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment