1919function URI (value:: AbstractString )
2020 m = match (r" ^(([^:/?#]+?):)?(\/\/ ([^/?#]*))?([^?#]*)(\? ([^#]*))?(#(.*))?" , value)
2121
22- m=== nothing && error (" Invalid argument." )
22+ m === nothing && error (" Invalid argument." )
2323
2424 return URI (
2525 m. captures[2 ],
26- m. captures[4 ]=== nothing ? nothing : percent_decode (m. captures[4 ]),
27- m. captures[5 ]=== nothing ? nothing : percent_decode (m. captures[5 ]),
28- m. captures[7 ]=== nothing ? nothing : percent_decode (m. captures[7 ]),
29- m. captures[9 ]=== nothing ? nothing : percent_decode (m. captures[9 ])
26+ m. captures[4 ] === nothing ? nothing : percent_decode (m. captures[4 ]),
27+ m. captures[5 ] === nothing ? nothing : percent_decode (m. captures[5 ]),
28+ m. captures[7 ] === nothing ? nothing : percent_decode (m. captures[7 ]),
29+ m. captures[9 ] === nothing ? nothing : percent_decode (m. captures[9 ])
3030 )
3131end
3232
@@ -36,58 +36,58 @@ function URI(;
3636 path:: AbstractString = " " ,
3737 query:: Union{AbstractString,Nothing} = nothing ,
3838 fragment:: Union{AbstractString,Nothing} = nothing
39- )
39+ )
4040 return URI (scheme, authority, path, query, fragment)
4141end
4242
4343@inline function is_rfc3986_unreserved (c:: Char )
4444 return ' A' <= c <= ' Z' ||
45- ' a' <= c <= ' z' ||
46- ' 0' <= c <= ' 9' ||
47- c == ' -' ||
48- c == ' .' ||
49- c == ' _' ||
50- c == ' ~'
45+ ' a' <= c <= ' z' ||
46+ ' 0' <= c <= ' 9' ||
47+ c == ' -' ||
48+ c == ' .' ||
49+ c == ' _' ||
50+ c == ' ~'
5151end
5252
5353@inline function is_rfc3986_sub_delim (c:: Char )
5454 return c == ' !' ||
55- c == ' $' ||
56- c == ' &' ||
57- c == ' \' ' ||
58- c == ' (' ||
59- c == ' )' ||
60- c == ' *' ||
61- c == ' +' ||
62- c == ' ,' ||
63- c == ' ;' ||
64- c == ' ='
55+ c == ' $' ||
56+ c == ' &' ||
57+ c == ' \' ' ||
58+ c == ' (' ||
59+ c == ' )' ||
60+ c == ' *' ||
61+ c == ' +' ||
62+ c == ' ,' ||
63+ c == ' ;' ||
64+ c == ' ='
6565end
6666
6767@inline function is_rfc3986_pchar (c:: Char )
6868 return is_rfc3986_unreserved (c) ||
69- is_rfc3986_sub_delim (c) ||
70- c == ' :' ||
71- c == ' @'
69+ is_rfc3986_sub_delim (c) ||
70+ c == ' :' ||
71+ c == ' @'
7272end
7373
7474@inline function is_rfc3986_query (c:: Char )
75- return is_rfc3986_pchar (c) || c== ' /' || c== ' ?'
75+ return is_rfc3986_pchar (c) || c == ' /' || c == ' ?'
7676end
7777
7878@inline function is_rfc3986_fragment (c:: Char )
79- return is_rfc3986_pchar (c) || c== ' /' || c== ' ?'
79+ return is_rfc3986_pchar (c) || c == ' /' || c == ' ?'
8080end
8181
8282@inline function is_rfc3986_userinfo (c:: Char )
8383 return is_rfc3986_unreserved (c) ||
84- is_rfc3986_sub_delim (c) ||
85- c == ' :'
84+ is_rfc3986_sub_delim (c) ||
85+ c == ' :'
8686end
8787
8888@inline function is_rfc3986_reg_name (c:: Char )
8989 return is_rfc3986_unreserved (c) ||
90- is_rfc3986_sub_delim (c)
90+ is_rfc3986_sub_delim (c)
9191end
9292
9393function encode (io:: IO , s:: AbstractString , issafe:: Function )
@@ -102,14 +102,14 @@ function encode(io::IO, s::AbstractString, issafe::Function)
102102end
103103
104104@inline function is_ipv4address (s:: AbstractString )
105- if length (s)== 1
105+ if length (s) == 1
106106 return ' 0' <= s[1 ] <= ' 9'
107- elseif length (s)== 2
107+ elseif length (s) == 2
108108 return ' 1' <= s[1 ] <= ' 9' && ' 0' <= s[2 ] <= ' 9'
109- elseif length (s)== 3
110- return (s[1 ]== ' 1' && ' 0' <= s[2 ] <= ' 9' && ' 0' <= s[3 ] <= ' 9' ) ||
111- (s[1 ]== ' 2' && ' 0' <= s[2 ] <= ' 4' && ' 0' <= s[3 ] <= ' 9' ) ||
112- (s[1 ]== ' 2' && s[2 ] == ' 5' && ' 0' <= s[3 ] <= ' 5' )
109+ elseif length (s) == 3
110+ return (s[1 ] == ' 1' && ' 0' <= s[2 ] <= ' 9' && ' 0' <= s[3 ] <= ' 9' ) ||
111+ (s[1 ] == ' 2' && ' 0' <= s[2 ] <= ' 4' && ' 0' <= s[3 ] <= ' 9' ) ||
112+ (s[1 ] == ' 2' && s[2 ] == ' 5' && ' 0' <= s[3 ] <= ' 5' )
113113 else
114114 return false
115115 end
@@ -141,44 +141,44 @@ function Base.print(io::IO, uri::URI)
141141 query = uri. query
142142 fragment = uri. fragment
143143
144- if scheme!= = nothing
144+ if scheme != = nothing
145145 print (io, scheme)
146146 print (io, ' :' )
147- end
147+ end
148148
149- if authority!= = nothing
149+ if authority != = nothing
150150 print (io, " //" )
151151
152- idx = findfirst (" @" , authority)
153- if idx != = nothing
154- # <user>@<auth>
155- userinfo = SubString (authority, 1 : idx. start- 1 )
156- host_and_port = SubString (authority, idx. start + 1 )
157- encode (io, userinfo, is_rfc3986_userinfo)
152+ idx = findfirst (" @" , authority)
153+ if idx != = nothing
154+ # <user>@<auth>
155+ userinfo = SubString (authority, 1 : idx. start- 1 )
156+ host_and_port = SubString (authority, idx. start + 1 )
157+ encode (io, userinfo, is_rfc3986_userinfo)
158158 print (io, ' @' )
159159 else
160160 host_and_port = SubString (authority, 1 )
161- end
161+ end
162162
163- idx3 = findfirst (" :" , host_and_port)
164- if idx3 === nothing
163+ idx3 = findfirst (" :" , host_and_port)
164+ if idx3 === nothing
165165 encode_host (io, host_and_port)
166- else
167- # <auth>:<port>
166+ else
167+ # <auth>:<port>
168168 encode_host (io, SubString (host_and_port, 1 : idx3. start- 1 ))
169- print (io, SubString (host_and_port, idx3. start))
169+ print (io, SubString (host_and_port, idx3. start))
170170 end
171- end
171+ end
172172
173- # Append path
174- encode_path (io, path)
173+ # Append path
174+ encode_path (io, path)
175175
176- if query!= = nothing
176+ if query != = nothing
177177 print (io, ' ?' )
178178 encode (io, query, is_rfc3986_query)
179179 end
180180
181- if fragment!= = nothing
181+ if fragment != = nothing
182182 print (io, ' #' )
183183 encode (io, fragment, is_rfc3986_fragment)
184184 end
0 commit comments