Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
1b6a1d2c
Commit
1b6a1d2c
authored
Nov 08, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(Utils/uri-tools): in progress
parent
f9bc26e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
107 additions
and
6 deletions
+107
-6
uri-tools.js
tests/ui/scripts/Utils/uri-tools.js
+107
-6
No files found.
tests/ui/scripts/Utils/uri-tools.js
View file @
1b6a1d2c
...
...
@@ -4,11 +4,11 @@
// Level 0. ----------------------------------------------------------
var
URI_PCT_ENCODED
=
'
(%[[:xdigit:]]{2})
'
var
URI_PORT
=
'
([
\\
d]*)
'
var
URI_SCHEME
=
'
([[:alpha:]][[:alnum:]+
\\
-.]*)
'
var
URI_PCT_ENCODED
=
'
%[A-Fa-f0-9]{2}
'
var
URI_PORT
=
'
[0-9]*
'
var
URI_SCHEME
=
'
[a-zA-Z][a-zA-Z0-9+
\
-
\
.]*
'
var
URI_SUB_DELIMS
=
'
[!$&
\'
()*+,;=]
'
var
URI_UNRESERVED
=
'
[
[:alnum:]
\\
-
._~]
'
var
URI_UNRESERVED
=
'
[
a-zA-Z0-9
\
-
\
._~]
'
// Level 1. ----------------------------------------------------------
...
...
@@ -90,15 +90,116 @@ var URI_HIER_PART = '(' +
// Level 5. ----------------------------------------------------------
// Regex to match URI. It respects the RFC 3986.
var
URI_REGEX
=
'
(
'
+
// But many features are not supported like IP format.
var
URI
=
'
(
'
+
URI_SCHEME
+
'
:
'
+
URI_HIER_PART
+
'
(
'
+
'
\\
?
'
+
URI_QUERY
+
'
)?
'
+
'
(
'
+
'
#
'
+
URI_FRAGMENT
+
'
)?
'
+
'
)
'
var
URI_REGEX
=
new
RegExp
(
URI
,
'
g
'
)
// ===================================================================
function
test
()
{
console
.
log
(
URI_REGEX
)
console
.
log
(
'
TOTO
'
,
URI_REGEX
)
console
.
log
(
'
http://99w-w*w.test.com
'
.
match
(
URI_REGEX
))
}
test
()
/*
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
hier-part = "//" authority path-abempty
/ path-absolute
/ path-rootless
/ path-empty
URI-reference = URI / relative-ref
absolute-URI = scheme ":" hier-part [ "?" query ]
relative-ref = relative-part [ "?" query ] [ "#" fragment ]
relative-part = "//" authority path-abempty
/ path-absolute
/ path-noscheme
/ path-empty
scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
authority = [ userinfo "@" ] host [ ":" port ]
userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
host = IP-literal / IPv4address / reg-name
port = *DIGIT
IP-literal = "[" ( IPv6address / IPvFuture ) "]"
IPvFuture = "v" 1*HEXDIG "." 1*( unreserved / sub-delims / ":" )
IPv6address = 6( h16 ":" ) ls32
/ "::" 5( h16 ":" ) ls32
/ [ h16 ] "::" 4( h16 ":" ) ls32
/ [ *1( h16 ":" ) h16 ] "::" 3( h16 ":" ) ls32
/ [ *2( h16 ":" ) h16 ] "::" 2( h16 ":" ) ls32
/ [ *3( h16 ":" ) h16 ] "::" h16 ":" ls32
/ [ *4( h16 ":" ) h16 ] "::" ls32
/ [ *5( h16 ":" ) h16 ] "::" h16
/ [ *6( h16 ":" ) h16 ] "::"
h16 = 1*4HEXDIG
ls32 = ( h16 ":" h16 ) / IPv4address
IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
Berners-Lee, et al. Standards Track [Page 49]
RFC 3986 URI Generic Syntax January 2005
dec-octet = DIGIT ; 0-9
/ %x31-39 DIGIT ; 10-99
/ "1" 2DIGIT ; 100-199
/ "2" %x30-34 DIGIT ; 200-249
/ "25" %x30-35 ; 250-255
reg-name = *( unreserved / pct-encoded / sub-delims )
path = path-abempty ; begins with "/" or is empty
/ path-absolute ; begins with "/" but not "//"
/ path-noscheme ; begins with a non-colon segment
/ path-rootless ; begins with a segment
/ path-empty ; zero characters
path-abempty = *( "/" segment )
path-absolute = "/" [ segment-nz *( "/" segment ) ]
path-noscheme = segment-nz-nc *( "/" segment )
path-rootless = segment-nz *( "/" segment )
path-empty = 0<pchar>
segment = *pchar
segment-nz = 1*pchar
segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
; non-zero-length segment without any colon ":"
pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
query = *( pchar / "/" / "?" )
fragment = *( pchar / "/" / "?" )
pct-encoded = "%" HEXDIG HEXDIG
unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
reserved = gen-delims / sub-delims
gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
/ "*" / "+" / "," / ";" / "="
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment