| 1 |
// Copyright Joyent, Inc. and other Node contributors. |
| 2 |
// |
| 3 |
// Permission is hereby granted, free of charge, to any person obtaining a |
| 4 |
// copy of this software and associated documentation files (the |
| 5 |
// "Software"), to deal in the Software without restriction, including |
| 6 |
// without limitation the rights to use, copy, modify, merge, publish, |
| 7 |
// distribute, sublicense, and/or sell copies of the Software, and to permit |
| 8 |
// persons to whom the Software is furnished to do so, subject to the |
| 9 |
// following conditions: |
| 10 |
// |
| 11 |
// The above copyright notice and this permission notice shall be included |
| 12 |
// in all copies or substantial portions of the Software. |
| 13 |
// |
| 14 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 |
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 16 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
| 17 |
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 18 |
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 19 |
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
| 20 |
// USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
|
| 22 |
'use strict'; |
| 23 |
|
| 24 |
/* eslint-disable no-script-url */ |
| 25 |
|
| 26 |
// URLs to parse, and expected data |
| 27 |
// { url : parsed } |
| 28 |
module.exports = { |
| 29 |
'//some_path' : { |
| 30 |
'pathname': '//some_path' |
| 31 |
}, |
| 32 |
|
| 33 |
'HTTP://www.example.com/' : { |
| 34 |
'protocol': 'HTTP:', |
| 35 |
'slashes': true, |
| 36 |
'hostname': 'www.example.com', |
| 37 |
'pathname': '/' |
| 38 |
}, |
| 39 |
|
| 40 |
'HTTP://www.example.com' : { |
| 41 |
'protocol': 'HTTP:', |
| 42 |
'slashes': true, |
| 43 |
'hostname': 'www.example.com', |
| 44 |
'pathname': '' |
| 45 |
}, |
| 46 |
|
| 47 |
'http://www.ExAmPlE.com/' : { |
| 48 |
'protocol': 'http:', |
| 49 |
'slashes': true, |
| 50 |
'hostname': 'www.ExAmPlE.com', |
| 51 |
'pathname': '/' |
| 52 |
}, |
| 53 |
|
| 54 |
'http://user:[email protected]/' : { |
| 55 |
'protocol': 'http:', |
| 56 |
'slashes': true, |
| 57 |
'auth': 'user:pw', |
| 58 |
'hostname': 'www.ExAmPlE.com', |
| 59 |
'pathname': '/' |
| 60 |
}, |
| 61 |
|
| 62 |
'http://USER:[email protected]/' : { |
| 63 |
'protocol': 'http:', |
| 64 |
'slashes': true, |
| 65 |
'auth': 'USER:PW', |
| 66 |
'hostname': 'www.ExAmPlE.com', |
| 67 |
'pathname': '/' |
| 68 |
}, |
| 69 |
|
| 70 |
'http://[email protected]/' : { |
| 71 |
'protocol': 'http:', |
| 72 |
'slashes': true, |
| 73 |
'auth': 'user', |
| 74 |
'hostname': 'www.example.com', |
| 75 |
'pathname': '/' |
| 76 |
}, |
| 77 |
|
| 78 |
'http://user%[email protected]/' : { |
| 79 |
'protocol': 'http:', |
| 80 |
'slashes': true, |
| 81 |
'auth': 'user%3Apw', |
| 82 |
'hostname': 'www.example.com', |
| 83 |
'pathname': '/' |
| 84 |
}, |
| 85 |
|
| 86 |
'http://x.com/path?that\'s#all, folks' : { |
| 87 |
'protocol': 'http:', |
| 88 |
'hostname': 'x.com', |
| 89 |
'slashes': true, |
| 90 |
'search': '?that\'s', |
| 91 |
'pathname': '/path', |
| 92 |
'hash': '#all, folks' |
| 93 |
}, |
| 94 |
|
| 95 |
'HTTP://X.COM/Y' : { |
| 96 |
'protocol': 'HTTP:', |
| 97 |
'slashes': true, |
| 98 |
'hostname': 'X.COM', |
| 99 |
'pathname': '/Y' |
| 100 |
}, |
| 101 |
|
| 102 |
// + not an invalid host character |
| 103 |
// per https://url.spec.whatwg.org/#host-parsing |
| 104 |
'http://x.y.com+a/b/c' : { |
| 105 |
'protocol': 'http:', |
| 106 |
'slashes': true, |
| 107 |
'hostname': 'x.y.com+a', |
| 108 |
'pathname': '/b/c' |
| 109 |
}, |
| 110 |
|
| 111 |
// an unexpected invalid char in the hostname. |
| 112 |
'HtTp://x.y.cOm;a/b/c?d=e#f g<h>i' : { |
| 113 |
'protocol': 'HtTp:', |
| 114 |
'slashes': true, |
| 115 |
'hostname': 'x.y.cOm', |
| 116 |
'pathname': ';a/b/c', |
| 117 |
'search': '?d=e', |
| 118 |
'hash': '#f g<h>i' |
| 119 |
}, |
| 120 |
|
| 121 |
// make sure that we don't accidentally lcast the path parts. |
| 122 |
'HtTp://x.y.cOm;A/b/c?d=e#f g<h>i' : { |
| 123 |
'protocol': 'HtTp:', |
| 124 |
'slashes': true, |
| 125 |
'hostname': 'x.y.cOm', |
| 126 |
'pathname': ';A/b/c', |
| 127 |
'search': '?d=e', |
| 128 |
'hash': '#f g<h>i' |
| 129 |
}, |
| 130 |
|
| 131 |
'http://x...y...#p': { |
| 132 |
'protocol': 'http:', |
| 133 |
'slashes': true, |
| 134 |
'hostname': 'x...y...', |
| 135 |
'hash': '#p', |
| 136 |
'pathname': '' |
| 137 |
}, |
| 138 |
|
| 139 |
'http://x/p/"quoted"': { |
| 140 |
'protocol': 'http:', |
| 141 |
'slashes': true, |
| 142 |
'hostname': 'x', |
| 143 |
'pathname': '/p/"quoted"' |
| 144 |
}, |
| 145 |
|
| 146 |
'<http://goo.corn/bread> Is a URL!': { |
| 147 |
'pathname': '<http://goo.corn/bread> Is a URL!' |
| 148 |
}, |
| 149 |
|
| 150 |
'http://www.narwhaljs.org/blog/categories?id=news' : { |
| 151 |
'protocol': 'http:', |
| 152 |
'slashes': true, |
| 153 |
'hostname': 'www.narwhaljs.org', |
| 154 |
'search': '?id=news', |
| 155 |
'pathname': '/blog/categories' |
| 156 |
}, |
| 157 |
|
| 158 |
'http://mt0.google.com/vt/lyrs=m@114&hl=en&src=api&x=2&y=2&z=3&s=' : { |
| 159 |
'protocol': 'http:', |
| 160 |
'slashes': true, |
| 161 |
'hostname': 'mt0.google.com', |
| 162 |
'pathname': '/vt/lyrs=m@114&hl=en&src=api&x=2&y=2&z=3&s=' |
| 163 |
}, |
| 164 |
|
| 165 |
'http://mt0.google.com/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=' : { |
| 166 |
'protocol': 'http:', |
| 167 |
'slashes': true, |
| 168 |
'hostname': 'mt0.google.com', |
| 169 |
'search': '???&hl=en&src=api&x=2&y=2&z=3&s=', |
| 170 |
'pathname': '/vt/lyrs=m@114' |
| 171 |
}, |
| 172 |
|
| 173 |
'http://user:[email protected]/vt/lyrs=m@114???&hl=en&src=api&x=2&y=2&z=3&s=': |
| 174 |
{ |
| 175 |
'protocol': 'http:', |
| 176 |
'slashes': true, |
| 177 |
'auth': 'user:pass', |
| 178 |
'hostname': 'mt0.google.com', |
| 179 |
'search': '???&hl=en&src=api&x=2&y=2&z=3&s=', |
| 180 |
'pathname': '/vt/lyrs=m@114' |
| 181 |
}, |
| 182 |
|
| 183 |
'file:///etc/passwd' : { |
| 184 |
'slashes': true, |
| 185 |
'protocol': 'file:', |
| 186 |
'pathname': '/etc/passwd', |
| 187 |
'hostname': '' |
| 188 |
}, |
| 189 |
|
| 190 |
'file://localhost/etc/passwd' : { |
| 191 |
'protocol': 'file:', |
| 192 |
'slashes': true, |
| 193 |
'pathname': '/etc/passwd', |
| 194 |
'hostname': 'localhost' |
| 195 |
}, |
| 196 |
|
| 197 |
'file://foo/etc/passwd' : { |
| 198 |
'protocol': 'file:', |
| 199 |
'slashes': true, |
| 200 |
'pathname': '/etc/passwd', |
| 201 |
'hostname': 'foo' |
| 202 |
}, |
| 203 |
|
| 204 |
'file:///etc/node/' : { |
| 205 |
'slashes': true, |
| 206 |
'protocol': 'file:', |
| 207 |
'pathname': '/etc/node/', |
| 208 |
'hostname': '' |
| 209 |
}, |
| 210 |
|
| 211 |
'file://localhost/etc/node/' : { |
| 212 |
'protocol': 'file:', |
| 213 |
'slashes': true, |
| 214 |
'pathname': '/etc/node/', |
| 215 |
'hostname': 'localhost' |
| 216 |
}, |
| 217 |
|
| 218 |
'file://foo/etc/node/' : { |
| 219 |
'protocol': 'file:', |
| 220 |
'slashes': true, |
| 221 |
'pathname': '/etc/node/', |
| 222 |
'hostname': 'foo' |
| 223 |
}, |
| 224 |
|
| 225 |
'http:/baz/../foo/bar' : { |
| 226 |
'protocol': 'http:', |
| 227 |
'pathname': '/baz/../foo/bar' |
| 228 |
}, |
| 229 |
|
| 230 |
'http://user:[email protected]:8000/foo/bar?baz=quux#frag' : { |
| 231 |
'protocol': 'http:', |
| 232 |
'slashes': true, |
| 233 |
'auth': 'user:pass', |
| 234 |
'port': '8000', |
| 235 |
'hostname': 'example.com', |
| 236 |
'hash': '#frag', |
| 237 |
'search': '?baz=quux', |
| 238 |
'pathname': '/foo/bar' |
| 239 |
}, |
| 240 |
|
| 241 |
'//user:[email protected]:8000/foo/bar?baz=quux#frag' : { |
| 242 |
'slashes': true, |
| 243 |
'auth': 'user:pass', |
| 244 |
'port': '8000', |
| 245 |
'hostname': 'example.com', |
| 246 |
'hash': '#frag', |
| 247 |
'search': '?baz=quux', |
| 248 |
'pathname': '/foo/bar' |
| 249 |
}, |
| 250 |
|
| 251 |
'/foo/bar?baz=quux#frag' : { |
| 252 |
'hash': '#frag', |
| 253 |
'search': '?baz=quux', |
| 254 |
'pathname': '/foo/bar' |
| 255 |
}, |
| 256 |
|
| 257 |
'http:/foo/bar?baz=quux#frag' : { |
| 258 |
'protocol': 'http:', |
| 259 |
'hash': '#frag', |
| 260 |
'search': '?baz=quux', |
| 261 |
'pathname': '/foo/bar' |
| 262 |
}, |
| 263 |
|
| 264 |
'mailto:[email protected]?subject=hello' : { |
| 265 |
'protocol': 'mailto:', |
| 266 |
'auth' : 'foo', |
| 267 |
'hostname' : 'bar.com', |
| 268 |
'search': '?subject=hello' |
| 269 |
}, |
| 270 |
|
| 271 |
'javascript:alert(\'hello\');' : { |
| 272 |
'protocol': 'javascript:', |
| 273 |
'pathname': 'alert(\'hello\');' |
| 274 |
}, |
| 275 |
|
| 276 |
'xmpp:[email protected]' : { |
| 277 |
'protocol': 'xmpp:', |
| 278 |
'auth': 'isaacschlueter', |
| 279 |
'hostname': 'jabber.org' |
| 280 |
}, |
| 281 |
|
| 282 |
'http://atpass:foo%[email protected]:8080/path?search=foo#bar' : { |
| 283 |
'protocol' : 'http:', |
| 284 |
'slashes': true, |
| 285 |
'auth' : 'atpass:foo%40bar', |
| 286 |
'hostname' : '127.0.0.1', |
| 287 |
'port' : '8080', |
| 288 |
'pathname': '/path', |
| 289 |
'search' : '?search=foo', |
| 290 |
'hash' : '#bar' |
| 291 |
}, |
| 292 |
|
| 293 |
'svn+ssh://foo/bar': { |
| 294 |
'hostname': 'foo', |
| 295 |
'protocol': 'svn+ssh:', |
| 296 |
'pathname': '/bar', |
| 297 |
'slashes': true |
| 298 |
}, |
| 299 |
|
| 300 |
'dash-test://foo/bar': { |
| 301 |
'hostname': 'foo', |
| 302 |
'protocol': 'dash-test:', |
| 303 |
'pathname': '/bar', |
| 304 |
'slashes': true |
| 305 |
}, |
| 306 |
|
| 307 |
'dash-test:foo/bar': { |
| 308 |
'hostname': 'foo', |
| 309 |
'protocol': 'dash-test:', |
| 310 |
'pathname': '/bar' |
| 311 |
}, |
| 312 |
|
| 313 |
'dot.test://foo/bar': { |
| 314 |
'hostname': 'foo', |
| 315 |
'protocol': 'dot.test:', |
| 316 |
'pathname': '/bar', |
| 317 |
'slashes': true |
| 318 |
}, |
| 319 |
|
| 320 |
'dot.test:foo/bar': { |
| 321 |
'hostname': 'foo', |
| 322 |
'protocol': 'dot.test:', |
| 323 |
'pathname': '/bar' |
| 324 |
}, |
| 325 |
|
| 326 |
// IDNA tests |
| 327 |
'http://www.日本語.com/' : { |
| 328 |
'protocol': 'http:', |
| 329 |
'slashes': true, |
| 330 |
'hostname': 'www.日本語.com', |
| 331 |
'pathname': '/' |
| 332 |
}, |
| 333 |
|
| 334 |
'http://example.Bücher.com/' : { |
| 335 |
'protocol': 'http:', |
| 336 |
'slashes': true, |
| 337 |
'hostname': 'example.Bücher.com', |
| 338 |
'pathname': '/' |
| 339 |
}, |
| 340 |
|
| 341 |
'http://www.Äffchen.com/' : { |
| 342 |
'protocol': 'http:', |
| 343 |
'slashes': true, |
| 344 |
'hostname': 'www.Äffchen.com', |
| 345 |
'pathname': '/' |
| 346 |
}, |
| 347 |
|
| 348 |
'http://www.Äffchen.cOm;A/b/c?d=e#f g<h>i' : { |
| 349 |
'protocol': 'http:', |
| 350 |
'slashes': true, |
| 351 |
'hostname': 'www.Äffchen.cOm', |
| 352 |
'pathname': ';A/b/c', |
| 353 |
'search': '?d=e', |
| 354 |
'hash': '#f g<h>i' |
| 355 |
}, |
| 356 |
|
| 357 |
'http://SÉLIER.COM/' : { |
| 358 |
'protocol': 'http:', |
| 359 |
'slashes': true, |
| 360 |
'hostname': 'SÉLIER.COM', |
| 361 |
'pathname': '/' |
| 362 |
}, |
| 363 |
|
| 364 |
'http://ليهمابتكلموشعربي؟.ي؟/' : { |
| 365 |
'protocol': 'http:', |
| 366 |
'slashes': true, |
| 367 |
'hostname': 'ليهمابتكلموشعربي؟.ي؟', |
| 368 |
'pathname': '/' |
| 369 |
}, |
| 370 |
|
| 371 |
'http://➡.ws/➡' : { |
| 372 |
'protocol': 'http:', |
| 373 |
'slashes': true, |
| 374 |
'hostname': '➡.ws', |
| 375 |
'pathname': '/➡' |
| 376 |
}, |
| 377 |
|
| 378 |
'http://bucket_name.s3.amazonaws.com/image.jpg': { |
| 379 |
protocol: 'http:', |
| 380 |
slashes: true, |
| 381 |
hostname: 'bucket_name.s3.amazonaws.com', |
| 382 |
pathname: '/image.jpg' |
| 383 |
}, |
| 384 |
|
| 385 |
'git+http://github.com/joyent/node.git': { |
| 386 |
protocol: 'git+http:', |
| 387 |
slashes: true, |
| 388 |
hostname: 'github.com', |
| 389 |
pathname: '/joyent/node.git' |
| 390 |
}, |
| 391 |
|
| 392 |
// if local1@domain1 is uses as a relative URL it may |
| 393 |
// be parse into auth@hostname, but here there is no |
| 394 |
// way to make it work in url.parse, I add the test to be explicit |
| 395 |
'local1@domain1': { |
| 396 |
'pathname': 'local1@domain1' |
| 397 |
}, |
| 398 |
|
| 399 |
// While this may seem counter-intuitive, a browser will parse |
| 400 |
// <a href='www.google.com'> as a path. |
| 401 |
'www.example.com' : { |
| 402 |
'pathname': 'www.example.com' |
| 403 |
}, |
| 404 |
|
| 405 |
// ipv6 support |
| 406 |
'[fe80::1]': { |
| 407 |
'pathname': '[fe80::1]' |
| 408 |
}, |
| 409 |
|
| 410 |
'coap://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]': { |
| 411 |
'protocol': 'coap:', |
| 412 |
'slashes': true, |
| 413 |
'hostname': 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210' |
| 414 |
}, |
| 415 |
|
| 416 |
'coap://[1080:0:0:0:8:800:200C:417A]:61616/': { |
| 417 |
'protocol': 'coap:', |
| 418 |
'slashes': true, |
| 419 |
'port': '61616', |
| 420 |
'hostname': '1080:0:0:0:8:800:200C:417A', |
| 421 |
'pathname': '/' |
| 422 |
}, |
| 423 |
|
| 424 |
'http://user:password@[3ffe:2a00:100:7031::1]:8080': { |
| 425 |
'protocol': 'http:', |
| 426 |
'slashes': true, |
| 427 |
'auth': 'user:password', |
| 428 |
'port': '8080', |
| 429 |
'hostname': '3ffe:2a00:100:7031::1', |
| 430 |
'pathname': '' |
| 431 |
}, |
| 432 |
|
| 433 |
'coap://u:p@[::192.9.5.5]:61616/.well-known/r?n=Temperature': { |
| 434 |
'protocol': 'coap:', |
| 435 |
'slashes': true, |
| 436 |
'auth': 'u:p', |
| 437 |
'port': '61616', |
| 438 |
'hostname': '::192.9.5.5', |
| 439 |
'search': '?n=Temperature', |
| 440 |
'pathname': '/.well-known/r' |
| 441 |
}, |
| 442 |
|
| 443 |
// empty port |
| 444 |
'http://example.com:': { |
| 445 |
'protocol': 'http:', |
| 446 |
'slashes': true, |
| 447 |
'hostname': 'example.com', |
| 448 |
'pathname': ':' |
| 449 |
}, |
| 450 |
|
| 451 |
'http://example.com:/a/b.html': { |
| 452 |
'protocol': 'http:', |
| 453 |
'slashes': true, |
| 454 |
'hostname': 'example.com', |
| 455 |
'pathname': ':/a/b.html' |
| 456 |
}, |
| 457 |
|
| 458 |
'http://example.com:?a=b': { |
| 459 |
'protocol': 'http:', |
| 460 |
'slashes': true, |
| 461 |
'hostname': 'example.com', |
| 462 |
'search': '?a=b', |
| 463 |
'pathname': ':' |
| 464 |
}, |
| 465 |
|
| 466 |
'http://example.com:#abc': { |
| 467 |
'protocol': 'http:', |
| 468 |
'slashes': true, |
| 469 |
'hostname': 'example.com', |
| 470 |
'hash': '#abc', |
| 471 |
'pathname': ':' |
| 472 |
}, |
| 473 |
|
| 474 |
'http://[fe80::1]:/a/b?a=b#abc': { |
| 475 |
'protocol': 'http:', |
| 476 |
'slashes': true, |
| 477 |
'hostname': 'fe80::1', |
| 478 |
'search': '?a=b', |
| 479 |
'hash': '#abc', |
| 480 |
'pathname': ':/a/b' |
| 481 |
}, |
| 482 |
|
| 483 |
'http://-lovemonsterz.tumblr.com/rss': { |
| 484 |
'protocol': 'http:', |
| 485 |
'slashes': true, |
| 486 |
'hostname': '-lovemonsterz.tumblr.com', |
| 487 |
'pathname': '/rss' |
| 488 |
}, |
| 489 |
|
| 490 |
'http://-lovemonsterz.tumblr.com:80/rss': { |
| 491 |
'protocol': 'http:', |
| 492 |
'slashes': true, |
| 493 |
'port': '80', |
| 494 |
'hostname': '-lovemonsterz.tumblr.com', |
| 495 |
'pathname': '/rss' |
| 496 |
}, |
| 497 |
|
| 498 |
'http://user:[email protected]/rss': { |
| 499 |
'protocol': 'http:', |
| 500 |
'slashes': true, |
| 501 |
'auth': 'user:pass', |
| 502 |
'hostname': '-lovemonsterz.tumblr.com', |
| 503 |
'pathname': '/rss' |
| 504 |
}, |
| 505 |
|
| 506 |
'http://user:[email protected]:80/rss': { |
| 507 |
'protocol': 'http:', |
| 508 |
'slashes': true, |
| 509 |
'auth': 'user:pass', |
| 510 |
'port': '80', |
| 511 |
'hostname': '-lovemonsterz.tumblr.com', |
| 512 |
'pathname': '/rss' |
| 513 |
}, |
| 514 |
|
| 515 |
'http://_jabber._tcp.google.com/test': { |
| 516 |
'protocol': 'http:', |
| 517 |
'slashes': true, |
| 518 |
'hostname': '_jabber._tcp.google.com', |
| 519 |
'pathname': '/test' |
| 520 |
}, |
| 521 |
|
| 522 |
'http://user:pass@_jabber._tcp.google.com/test': { |
| 523 |
'protocol': 'http:', |
| 524 |
'slashes': true, |
| 525 |
'auth': 'user:pass', |
| 526 |
'hostname': '_jabber._tcp.google.com', |
| 527 |
'pathname': '/test' |
| 528 |
}, |
| 529 |
|
| 530 |
'http://_jabber._tcp.google.com:80/test': { |
| 531 |
'protocol': 'http:', |
| 532 |
'slashes': true, |
| 533 |
'port': '80', |
| 534 |
'hostname': '_jabber._tcp.google.com', |
| 535 |
'pathname': '/test' |
| 536 |
}, |
| 537 |
|
| 538 |
'http://user:pass@_jabber._tcp.google.com:80/test': { |
| 539 |
'protocol': 'http:', |
| 540 |
'slashes': true, |
| 541 |
'auth': 'user:pass', |
| 542 |
'port': '80', |
| 543 |
'hostname': '_jabber._tcp.google.com', |
| 544 |
'pathname': '/test' |
| 545 |
}, |
| 546 |
|
| 547 |
'http://x:1/\' <>"`/{}|\\^~`/': { |
| 548 |
protocol: 'http:', |
| 549 |
slashes: true, |
| 550 |
port: '1', |
| 551 |
hostname: 'x', |
| 552 |
pathname: '/\' <>"`/{}|\\^~`/' |
| 553 |
}, |
| 554 |
|
| 555 |
'http://a@b@c/': { |
| 556 |
protocol: 'http:', |
| 557 |
slashes: true, |
| 558 |
auth: 'a@b', |
| 559 |
hostname: 'c', |
| 560 |
pathname: '/' |
| 561 |
}, |
| 562 |
|
| 563 |
'http://a@b?@c': { |
| 564 |
protocol: 'http:', |
| 565 |
slashes: true, |
| 566 |
auth: 'a', |
| 567 |
hostname: 'b', |
| 568 |
pathname: '', |
| 569 |
search: '?@c' |
| 570 |
}, |
| 571 |
|
| 572 |
'http://a\r" \t\n<\'b:b@c\r\nd/e?f':{ |
| 573 |
protocol: 'http:', |
| 574 |
slashes: true, |
| 575 |
auth: 'a\r" \t\n<\'b:b', |
| 576 |
hostname: 'c', |
| 577 |
search: '?f', |
| 578 |
pathname: '\r\nd/e' |
| 579 |
}, |
| 580 |
|
| 581 |
// git urls used by npm |
| 582 |
'git+ssh://[email protected]:npm/npm': { |
| 583 |
protocol: 'git+ssh:', |
| 584 |
slashes: true, |
| 585 |
auth: 'git', |
| 586 |
hostname: 'github.com', |
| 587 |
pathname: ':npm/npm' |
| 588 |
}, |
| 589 |
|
| 590 |
'http://example.com?foo=bar#frag' : { |
| 591 |
'protocol': 'http:', |
| 592 |
'slashes': true, |
| 593 |
'hostname': 'example.com', |
| 594 |
'hash': '#frag', |
| 595 |
'search': '?foo=bar', |
| 596 |
'pathname': '' |
| 597 |
}, |
| 598 |
|
| 599 |
'http://example.com?foo=@bar#frag' : { |
| 600 |
'protocol': 'http:', |
| 601 |
'slashes': true, |
| 602 |
'hostname': 'example.com', |
| 603 |
'hash': '#frag', |
| 604 |
'search': '?foo=@bar', |
| 605 |
'pathname': '' |
| 606 |
}, |
| 607 |
|
| 608 |
'http://example.com?foo=/bar/#frag' : { |
| 609 |
'protocol': 'http:', |
| 610 |
'slashes': true, |
| 611 |
'hostname': 'example.com', |
| 612 |
'hash': '#frag', |
| 613 |
'search': '?foo=/bar/', |
| 614 |
'pathname': '' |
| 615 |
}, |
| 616 |
|
| 617 |
'http://example.com?foo=?bar/#frag' : { |
| 618 |
'protocol': 'http:', |
| 619 |
'slashes': true, |
| 620 |
'hostname': 'example.com', |
| 621 |
'hash': '#frag', |
| 622 |
'search': '?foo=?bar/', |
| 623 |
'pathname': '' |
| 624 |
}, |
| 625 |
|
| 626 |
'http://example.com#frag=?bar/#frag' : { |
| 627 |
'protocol': 'http:', |
| 628 |
'slashes': true, |
| 629 |
'hostname': 'example.com', |
| 630 |
'hash': '#frag=?bar/#frag', |
| 631 |
'pathname': '' |
| 632 |
}, |
| 633 |
|
| 634 |
'http://google.com" onload="alert(42)/' : { |
| 635 |
'hostname': 'google.com', |
| 636 |
'protocol': 'http:', |
| 637 |
'slashes': true, |
| 638 |
'pathname': '" onload="alert(42)/' |
| 639 |
}, |
| 640 |
|
| 641 |
'http://a.com/a/b/c?s#h' : { |
| 642 |
'protocol': 'http:', |
| 643 |
'slashes': true, |
| 644 |
'pathname': '/a/b/c', |
| 645 |
'hostname': 'a.com', |
| 646 |
'hash': '#h', |
| 647 |
'search': '?s' |
| 648 |
}, |
| 649 |
|
| 650 |
'http://atpass:foo%[email protected]/' : { |
| 651 |
'auth': 'atpass:foo%40bar', |
| 652 |
'slashes': true, |
| 653 |
'hostname': '127.0.0.1', |
| 654 |
'protocol': 'http:', |
| 655 |
'pathname': '/' |
| 656 |
}, |
| 657 |
|
| 658 |
'http://atslash%2F%40:%2F%40@foo/' : { |
| 659 |
'auth': 'atslash%2F%40:%2F%40', |
| 660 |
'hostname': 'foo', |
| 661 |
'protocol': 'http:', |
| 662 |
'pathname': '/', |
| 663 |
'slashes': true |
| 664 |
}, |
| 665 |
|
| 666 |
// ipv6 support |
| 667 |
'coap:u:p@[::1]:61616/.well-known/r?n=Temperature': { |
| 668 |
'protocol': 'coap:', |
| 669 |
'auth': 'u:p', |
| 670 |
'hostname': '::1', |
| 671 |
'port': '61616', |
| 672 |
'pathname': '/.well-known/r', |
| 673 |
'search': '?n=Temperature' |
| 674 |
}, |
| 675 |
|
| 676 |
'coap:[fedc:ba98:7654:3210:fedc:ba98:7654:3210]:61616/s/stopButton': { |
| 677 |
'hostname': 'fedc:ba98:7654:3210:fedc:ba98:7654:3210', |
| 678 |
'port': '61616', |
| 679 |
'protocol': 'coap:', |
| 680 |
'pathname': '/s/stopButton' |
| 681 |
}, |
| 682 |
|
| 683 |
// encode context-specific delimiters in path and query, but do not touch |
| 684 |
// other non-delimiter chars like `%`. |
| 685 |
// <https://github.com/joyent/node/issues/4082> |
| 686 |
|
| 687 |
// `?` and `#` in path and search |
| 688 |
'http://ex.com/foo%3F100%m%23r?abc=the%231?&foo=bar#frag': { |
| 689 |
protocol: 'http:', |
| 690 |
hostname: 'ex.com', |
| 691 |
hash: '#frag', |
| 692 |
search: '?abc=the%231?&foo=bar', |
| 693 |
pathname: '/foo%3F100%m%23r', |
| 694 |
slashes: true |
| 695 |
}, |
| 696 |
|
| 697 |
// `?` and `#` in search only |
| 698 |
'http://ex.com/fooA100%mBr?abc=the%231?&foo=bar#frag': { |
| 699 |
protocol: 'http:', |
| 700 |
hostname: 'ex.com', |
| 701 |
hash: '#frag', |
| 702 |
search: '?abc=the%231?&foo=bar', |
| 703 |
pathname: '/fooA100%mBr', |
| 704 |
slashes: true |
| 705 |
} |
| 706 |
}; |