Last active
April 7, 2017 13:21
-
-
Save MadeByMike/489747a0ffe412fba47c31f04a6513c0 to your computer and use it in GitHub Desktop.
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
valid_url = new RegExp( | |
"^" + | |
"(?:" + | |
// $1 protocol | |
"([a-z\\u00a1-\\uffff0-9]+-?)?" + | |
"(?:(?:\\:)?//)"+ | |
// $2 username:password | |
"(?:((?:\\S*)(?::\\S*)?)@)?" + | |
// $3 Hostname | |
"("+ | |
"(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}"+ | |
"(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"+ | |
"|"+ | |
"(?:(?:[a-z\\u00a1-\\uffff0-9]|[a-z\\u00a1-\\uffff0-9][a-z0-9\\u00a1-\\uffff\\-]*[a-z0-9\\u00a1-\\uffff])\\.)*"+ | |
"(?:[a-z\\u00a1-\\uffff]|[a-z\\u00a1-\\uffff][a-z0-9\\u00a1-\\uffff\\-]*[a-z0-9\\u00a1-\\uffff])"+ | |
"|"+ | |
"(?:"+ | |
"(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))"+ | |
"|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))"+ | |
"|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))"+ | |
"|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))"+ | |
"|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))"+ | |
"|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))"+ | |
"|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))"+ | |
"|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))"+ | |
")"+ | |
")"+ | |
// $4 Port | |
"(?::(\\d{2,5}))?" + | |
")?" + | |
// $5 Path | |
"("+ | |
"(?:(?:[\\/])|(?:\\.{2})||(?:\\.{1})|(?:^[a-z\\u00a1-\\uffff]))" + | |
"(?:[^\\?^#^:]*)" + | |
")?" + | |
// $6 Query | |
"(?:\\?([^\\#]+)*)?"+ | |
// $7 Hash | |
"(?:\\#(\\S*))?"+ | |
"$", "i" | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment