1414
1515@static if Sys. iswindows ()
1616 function Base.:(== )(a:: URI , b:: URI )
17- if a. scheme== " file" && b. scheme== " file"
17+ if a. scheme == " file" && b. scheme == " file"
1818 a_path_norm = lowercase (a. path)
1919 b_path_norm = lowercase (b. path)
2020
2121 return a. scheme == b. scheme &&
22- a. authority == b. authority &&
23- a_path_norm == b_path_norm &&
24- a. query == b. query &&
25- a. fragment == b. fragment
22+ a. authority == b. authority &&
23+ a_path_norm == b_path_norm &&
24+ a. query == b. query &&
25+ a. fragment == b. fragment
2626 else
2727 return a. scheme == b. scheme &&
28- a. authority == b. authority &&
29- a. path == b. path &&
30- a. query == b. query &&
31- a. fragment == b. fragment
28+ a. authority == b. authority &&
29+ a. path == b. path &&
30+ a. query == b. query &&
31+ a. fragment == b. fragment
3232 end
3333 end
3434
3535 function Base. hash (a:: URI , h:: UInt )
36- if a. scheme== " file"
36+ if a. scheme == " file"
3737 path_norm = lowercase (a. path)
3838 return hash ((a. scheme, a. authority, path_norm, a. query, a. fragment), h)
3939 else
4949function URI (value:: AbstractString )
5050 m = match (r" ^(([^:/?#]+?):)?(\/\/ ([^/?#]*))?([^?#]*)(\? ([^#]*))?(#(.*))?" , value)
5151
52- m=== nothing && error (" Invalid argument." )
52+ m === nothing && error (" Invalid argument." )
5353
5454 return URI (
5555 m. captures[2 ],
56- m. captures[4 ]=== nothing ? nothing : percent_decode (m. captures[4 ]),
57- m. captures[5 ]=== nothing ? nothing : percent_decode (m. captures[5 ]),
58- m. captures[7 ]=== nothing ? nothing : percent_decode (m. captures[7 ]),
59- m. captures[9 ]=== nothing ? nothing : percent_decode (m. captures[9 ])
56+ m. captures[4 ] === nothing ? nothing : percent_decode (m. captures[4 ]),
57+ m. captures[5 ] === nothing ? nothing : percent_decode (m. captures[5 ]),
58+ m. captures[7 ] === nothing ? nothing : percent_decode (m. captures[7 ]),
59+ m. captures[9 ] === nothing ? nothing : percent_decode (m. captures[9 ])
6060 )
6161end
6262
@@ -68,58 +68,58 @@ function URI(;
6868 path:: AbstractString = " " ,
6969 query:: Union{AbstractString,Nothing} = nothing ,
7070 fragment:: Union{AbstractString,Nothing} = nothing
71- )
71+ )
7272 return URI (scheme, authority, path, query, fragment)
7373end
7474
7575@inline function is_rfc3986_unreserved (c:: Char )
7676 return ' A' <= c <= ' Z' ||
77- ' a' <= c <= ' z' ||
78- ' 0' <= c <= ' 9' ||
79- c == ' -' ||
80- c == ' .' ||
81- c == ' _' ||
82- c == ' ~'
77+ ' a' <= c <= ' z' ||
78+ ' 0' <= c <= ' 9' ||
79+ c == ' -' ||
80+ c == ' .' ||
81+ c == ' _' ||
82+ c == ' ~'
8383end
8484
8585@inline function is_rfc3986_sub_delim (c:: Char )
8686 return c == ' !' ||
87- c == ' $' ||
88- c == ' &' ||
89- c == ' \' ' ||
90- c == ' (' ||
91- c == ' )' ||
92- c == ' *' ||
93- c == ' +' ||
94- c == ' ,' ||
95- c == ' ;' ||
96- c == ' ='
87+ c == ' $' ||
88+ c == ' &' ||
89+ c == ' \' ' ||
90+ c == ' (' ||
91+ c == ' )' ||
92+ c == ' *' ||
93+ c == ' +' ||
94+ c == ' ,' ||
95+ c == ' ;' ||
96+ c == ' ='
9797end
9898
9999@inline function is_rfc3986_pchar (c:: Char )
100100 return is_rfc3986_unreserved (c) ||
101- is_rfc3986_sub_delim (c) ||
102- c == ' :' ||
103- c == ' @'
101+ is_rfc3986_sub_delim (c) ||
102+ c == ' :' ||
103+ c == ' @'
104104end
105105
106106@inline function is_rfc3986_query (c:: Char )
107- return is_rfc3986_pchar (c) || c== ' /' || c== ' ?'
107+ return is_rfc3986_pchar (c) || c == ' /' || c == ' ?'
108108end
109109
110110@inline function is_rfc3986_fragment (c:: Char )
111- return is_rfc3986_pchar (c) || c== ' /' || c== ' ?'
111+ return is_rfc3986_pchar (c) || c == ' /' || c == ' ?'
112112end
113113
114114@inline function is_rfc3986_userinfo (c:: Char )
115115 return is_rfc3986_unreserved (c) ||
116- is_rfc3986_sub_delim (c) ||
117- c == ' :'
116+ is_rfc3986_sub_delim (c) ||
117+ c == ' :'
118118end
119119
120120@inline function is_rfc3986_reg_name (c:: Char )
121121 return is_rfc3986_unreserved (c) ||
122- is_rfc3986_sub_delim (c)
122+ is_rfc3986_sub_delim (c)
123123end
124124
125125function encode (io:: IO , s:: AbstractString , issafe:: Function )
@@ -134,14 +134,14 @@ function encode(io::IO, s::AbstractString, issafe::Function)
134134end
135135
136136@inline function is_ipv4address (s:: AbstractString )
137- if length (s)== 1
137+ if length (s) == 1
138138 return ' 0' <= s[1 ] <= ' 9'
139- elseif length (s)== 2
139+ elseif length (s) == 2
140140 return ' 1' <= s[1 ] <= ' 9' && ' 0' <= s[2 ] <= ' 9'
141- elseif length (s)== 3
142- return (s[1 ]== ' 1' && ' 0' <= s[2 ] <= ' 9' && ' 0' <= s[3 ] <= ' 9' ) ||
143- (s[1 ]== ' 2' && ' 0' <= s[2 ] <= ' 4' && ' 0' <= s[3 ] <= ' 9' ) ||
144- (s[1 ]== ' 2' && s[2 ] == ' 5' && ' 0' <= s[3 ] <= ' 5' )
141+ elseif length (s) == 3
142+ return (s[1 ] == ' 1' && ' 0' <= s[2 ] <= ' 9' && ' 0' <= s[3 ] <= ' 9' ) ||
143+ (s[1 ] == ' 2' && ' 0' <= s[2 ] <= ' 4' && ' 0' <= s[3 ] <= ' 9' ) ||
144+ (s[1 ] == ' 2' && s[2 ] == ' 5' && ' 0' <= s[3 ] <= ' 5' )
145145 else
146146 return false
147147 end
@@ -173,44 +173,44 @@ function Base.print(io::IO, uri::URI)
173173 query = uri. query
174174 fragment = uri. fragment
175175
176- if scheme!= = nothing
176+ if scheme != = nothing
177177 print (io, scheme)
178178 print (io, ' :' )
179- end
179+ end
180180
181- if authority!= = nothing
181+ if authority != = nothing
182182 print (io, " //" )
183183
184- idx = findfirst (" @" , authority)
185- if idx != = nothing
186- # <user>@<auth>
187- userinfo = SubString (authority, 1 : idx. start- 1 )
188- host_and_port = SubString (authority, idx. start + 1 )
189- encode (io, userinfo, is_rfc3986_userinfo)
184+ idx = findfirst (" @" , authority)
185+ if idx != = nothing
186+ # <user>@<auth>
187+ userinfo = SubString (authority, 1 : idx. start- 1 )
188+ host_and_port = SubString (authority, idx. start + 1 )
189+ encode (io, userinfo, is_rfc3986_userinfo)
190190 print (io, ' @' )
191191 else
192192 host_and_port = SubString (authority, 1 )
193- end
193+ end
194194
195- idx3 = findfirst (" :" , host_and_port)
196- if idx3 === nothing
195+ idx3 = findfirst (" :" , host_and_port)
196+ if idx3 === nothing
197197 encode_host (io, host_and_port)
198- else
199- # <auth>:<port>
198+ else
199+ # <auth>:<port>
200200 encode_host (io, SubString (host_and_port, 1 : idx3. start- 1 ))
201- print (io, SubString (host_and_port, idx3. start))
201+ print (io, SubString (host_and_port, idx3. start))
202202 end
203- end
203+ end
204204
205- # Append path
206- encode_path (io, path)
205+ # Append path
206+ encode_path (io, path)
207207
208- if query!= = nothing
208+ if query != = nothing
209209 print (io, ' ?' )
210210 encode (io, query, is_rfc3986_query)
211211 end
212212
213- if fragment!= = nothing
213+ if fragment != = nothing
214214 print (io, ' #' )
215215 encode (io, fragment, is_rfc3986_fragment)
216216 end
0 commit comments