Created
November 20, 2016 03:53
-
-
Save samcv/5ee9cf0aa6386902e49016f6e4a672f7 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
grammar url { | |
regex TOP { <anyprotocol> '://' <base> [ ['/' <term>]+ ]? '/'? } | |
token anyprotocol { <[ a..z A..Z ]> <[ a..z A..Z 0..9 . + - ]>+ } | |
token protocol {:i [http|https|ftp|git|ssh] } | |
token baseascii { [ <[a..z A..Z 0..9 \- . ]> ]+ } | |
token base { [ <:Number + :Letter + [ . - ]> ]+ } | |
token protected { <[ $ + ! * ( ) , . ; ? @ = % & # " ' ]> } | |
token allowed { \S } | |
regex term { <allowed>+ <!after <protected>> } | |
# token after { '/' <term> } | |
} | |
say url.parse("https://google.com"); | |
say url.parse("https://google.com/something"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment