Skip to content

Instantly share code, notes, and snippets.

@dmitriid
Last active April 9, 2022 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmitriid/f64fa7c3a6000e0170a9d911445bc1f3 to your computer and use it in GitHub Desktop.
Save dmitriid/f64fa7c3a6000e0170a9d911445bc1f3 to your computer and use it in GitHub Desktop.
scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]
(file|ftp|https|http|irc|mailto):\/\/((\w+(:\w+)?@)?\w(\w\.?)*(:\d{1,5})?\/?)?(\w(\w+\/)*)?(#\w+)?
---
scheme = (file|ftp|https|http|irc|mailto):\/\/
optional username followed by optional :password. Username and password ar alphanumeric
|
v
user = (\w+(:\w+)?@)?
an alphanumeric char followed by (any number of characters optionally followed by a period)
|
v
host = \w(\w\.?)*
optional port, 1 to 5 digits
|
v
port = (:\d{1,5})?
optional (alphanumeric char followed by any number of alphanumeric characters interspereced with /)
|
v
path = (\w(\w+\/)*)?
optional characters following ?. As long as those characters are not #
|
v
query = (\?[^#]+)?
optional anything following #
|
v
query = (#.+)?
----
combine together. The entirety of (user host port) is optional
scheme
(user
host
port)?
path
query
fragment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment