@@ -163,6 +163,56 @@ test 'match', (t) ->
163
163
version : ' 1'
164
164
t .equal null , pattern .match (' /vvv1.1/resource' )
165
165
166
+ pattern = new UrlPattern ' /api/users/:id' ,
167
+ segmentValueCharset : ' a-zA-Z0-9-_~ %.@'
168
+ t .
deepEqual pattern .
match (
' /api/users/[email protected] ' ),
169
+
170
+
171
+ pattern = new UrlPattern ' /api/users?username=:username' ,
172
+ segmentValueCharset : ' a-zA-Z0-9-_~ %.@'
173
+ t .
deepEqual pattern .
match (
' /api/[email protected] ' ),
174
+
175
+
176
+ pattern = new UrlPattern ' /api/users?param1=:param1¶m2=:param2'
177
+ t .deepEqual pattern .match (' /api/users?param1=foo¶m2=bar' ),
178
+ param1 : ' foo'
179
+ param2 : ' bar'
180
+
181
+ pattern = new UrlPattern ' :scheme\\ ://:host(\\ ::port)' ,
182
+ segmentValueCharset : ' a-zA-Z0-9-_~ %.'
183
+ t .deepEqual pattern .match (' ftp://ftp.example.com' ),
184
+ scheme : ' ftp'
185
+ host : ' ftp.example.com'
186
+ t .deepEqual pattern .match (' ftp://ftp.example.com:8080' ),
187
+ scheme : ' ftp'
188
+ host : ' ftp.example.com'
189
+ port : ' 8080'
190
+ t .deepEqual pattern .match (' https://example.com:80' ),
191
+ scheme : ' https'
192
+ host : ' example.com'
193
+ port : ' 80'
194
+
195
+ pattern = new UrlPattern ' :scheme\\ ://:host(\\ ::port)(/api(/:resource(/:id)))' ,
196
+ segmentValueCharset : ' a-zA-Z0-9-_~ %.@'
197
+ t .deepEqual pattern .match (' https://sss.www.localhost.com' ),
198
+ scheme : ' https'
199
+ host : ' sss.www.localhost.com'
200
+ t .deepEqual pattern .match (' https://sss.www.localhost.com:8080' ),
201
+ scheme : ' https'
202
+ host : ' sss.www.localhost.com'
203
+ port : ' 8080'
204
+ t .deepEqual pattern .match (' https://sss.www.localhost.com/api' ),
205
+ scheme : ' https'
206
+ host : ' sss.www.localhost.com'
207
+ t .deepEqual pattern .match (' https://sss.www.localhost.com/api/security' ),
208
+ scheme : ' https'
209
+ host : ' sss.www.localhost.com'
210
+ resource : ' security'
211
+ t .
deepEqual pattern .
match (
' https://sss.www.localhost.com/api/security/[email protected] ' ),
212
+ scheme : ' https'
213
+ host : ' sss.www.localhost.com'
214
+ resource : ' security'
215
+
166
216
167
217
regex = / \/ ip\/ (25[0-5 ] | 2[0-4 ][0-9 ] | [01] ? [0-9 ][0-9 ] ? )\. (25[0-5 ] | 2[0-4 ][0-9 ] | [01] ? [0-9 ][0-9 ] ? )\. (25[0-5 ] | 2[0-4 ][0-9 ] | [01] ? [0-9 ][0-9 ] ? )\. (25[0-5 ] | 2[0-4 ][0-9 ] | [01] ? [0-9 ][0-9 ] ? )$ /
168
218
pattern = new UrlPattern regex
0 commit comments