Commit 6b19193f authored by Ronan Abhamon's avatar Ronan Abhamon

feat(Utils/uri-tools): in progress

parent 0d40db41
...@@ -20,32 +20,25 @@ var URI_HOST = '(' + ...@@ -20,32 +20,25 @@ var URI_HOST = '(' +
')*' + ')*' +
')' ')'
var URI_PCHAR = '(' + var URI_PCHAR = '(?:' +
URI_UNRESERVED + URI_UNRESERVED +
'|' + URI_PCT_ENCODED + '|' + URI_PCT_ENCODED +
'|' + URI_SUB_DELIMS + '|' + URI_SUB_DELIMS +
'|' + '[:@]' + '|' + '[:@]' +
')' ')'
var URI_USERINFO = '(?:' +
var URI_USERINFO = '(' + URI_UNRESERVED +
'(' + '|' + URI_PCT_ENCODED +
URI_UNRESERVED + '|' + URI_SUB_DELIMS +
'|' + URI_PCT_ENCODED + '|' + ':' +
'|' + URI_SUB_DELIMS + ')*'
'|' + ':' +
')*' +
')'
// Level 2. ---------------------------------------------------------- // Level 2. ----------------------------------------------------------
var URI_AUTHORITY = '(' + var URI_AUTHORITY = '(?:' + URI_USERINFO + '@' + ')?' +
'(' + URI_HOST +
URI_USERINFO + '@' + '(?:' + ':' + URI_PORT + ')?'
')?' + URI_HOST + '(' +
':' + URI_PORT +
')?' +
')'
var URI_FRAGMENT = '(?:' + var URI_FRAGMENT = '(?:' +
URI_PCHAR + URI_PCHAR +
...@@ -62,21 +55,17 @@ var URI_SEGMENT_NZ = URI_PCHAR + '+' ...@@ -62,21 +55,17 @@ var URI_SEGMENT_NZ = URI_PCHAR + '+'
// Level 3. ---------------------------------------------------------- // Level 3. ----------------------------------------------------------
var URI_PATH_ABEMPTY = '(' + '(' + '/' + URI_SEGMENT + ')*' + ')' var URI_PATH_ABEMPTY = '(?:' + '/' + URI_SEGMENT + ')*'
var URI_PATH_ABSOLUTE = '(' + var URI_PATH_ABSOLUTE = '/' +
'/' + '(' + '(?:' + URI_SEGMENT_NZ + '(?:' + '/' + URI_SEGMENT + ')*' + ')?'
URI_SEGMENT_NZ + '(' + '/' + URI_SEGMENT + ')*' +
')?' +
')'
var URI_PATH_ROOTLESS = '(' + var URI_PATH_ROOTLESS =
URI_SEGMENT_NZ + '(' + '/' + URI_SEGMENT + ')*' + URI_SEGMENT_NZ + '(?:' + '/' + URI_SEGMENT + ')*'
')'
// Level 4. ---------------------------------------------------------- // Level 4. ----------------------------------------------------------
var URI_HIER_PART = '(' + var URI_HIER_PART = '(?:' +
'//' + URI_AUTHORITY + URI_PATH_ABEMPTY + '//' + URI_AUTHORITY + URI_PATH_ABEMPTY +
'|' + URI_PATH_ABSOLUTE + '|' + URI_PATH_ABSOLUTE +
'|' + URI_PATH_ROOTLESS + '|' + URI_PATH_ROOTLESS +
...@@ -100,8 +89,7 @@ function test () { ...@@ -100,8 +89,7 @@ function test () {
} }
test() test()
/* /* TODO: Supports:
hier-part = "//" authority path-abempty hier-part = "//" authority path-abempty
/ path-absolute / path-absolute
/ path-rootless / path-rootless
...@@ -118,10 +106,6 @@ test() ...@@ -118,10 +106,6 @@ test()
/ path-noscheme / path-noscheme
/ path-empty / path-empty
scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
authority = [ userinfo "@" ] host [ ":" port ]
userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
host = IP-literal / IPv4address / reg-name host = IP-literal / IPv4address / reg-name
IP-literal = "[" ( IPv6address / IPvFuture ) "]" IP-literal = "[" ( IPv6address / IPvFuture ) "]"
...@@ -156,18 +140,12 @@ test() ...@@ -156,18 +140,12 @@ test()
/ path-rootless ; begins with a segment / path-rootless ; begins with a segment
/ path-empty ; zero characters / path-empty ; zero characters
path-abempty = *( "/" segment )
path-absolute = "/" [ segment-nz *( "/" segment ) ]
path-noscheme = segment-nz-nc *( "/" segment ) path-noscheme = segment-nz-nc *( "/" segment )
path-rootless = segment-nz *( "/" segment )
path-empty = 0<pchar> path-empty = 0<pchar>
segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" ) segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
; non-zero-length segment without any colon ":" ; non-zero-length segment without any colon ":"
pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
reserved = gen-delims / sub-delims reserved = gen-delims / sub-delims
gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@" gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
*/ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment