URL joining tests, as-per reference examples in RFC 3986. https://tools.ietf.org/html/rfc3986#section-5.4
()
| 500 | |
| 501 | |
| 502 | def test_url_join_rfc3986(): |
| 503 | """ |
| 504 | URL joining tests, as-per reference examples in RFC 3986. |
| 505 | |
| 506 | https://tools.ietf.org/html/rfc3986#section-5.4 |
| 507 | """ |
| 508 | |
| 509 | url = httpx.URL("http://example.com/b/c/d;p?q") |
| 510 | |
| 511 | assert url.join("g") == "http://example.com/b/c/g" |
| 512 | assert url.join("./g") == "http://example.com/b/c/g" |
| 513 | assert url.join("g/") == "http://example.com/b/c/g/" |
| 514 | assert url.join("/g") == "http://example.com/g" |
| 515 | assert url.join("//g") == "http://g" |
| 516 | assert url.join("?y") == "http://example.com/b/c/d;p?y" |
| 517 | assert url.join("g?y") == "http://example.com/b/c/g?y" |
| 518 | assert url.join("#s") == "http://example.com/b/c/d;p?q#s" |
| 519 | assert url.join("g#s") == "http://example.com/b/c/g#s" |
| 520 | assert url.join("g?y#s") == "http://example.com/b/c/g?y#s" |
| 521 | assert url.join(";x") == "http://example.com/b/c/;x" |
| 522 | assert url.join("g;x") == "http://example.com/b/c/g;x" |
| 523 | assert url.join("g;x?y#s") == "http://example.com/b/c/g;x?y#s" |
| 524 | assert url.join("") == "http://example.com/b/c/d;p?q" |
| 525 | assert url.join(".") == "http://example.com/b/c/" |
| 526 | assert url.join("./") == "http://example.com/b/c/" |
| 527 | assert url.join("..") == "http://example.com/b/" |
| 528 | assert url.join("../") == "http://example.com/b/" |
| 529 | assert url.join("../g") == "http://example.com/b/g" |
| 530 | assert url.join("../..") == "http://example.com/" |
| 531 | assert url.join("../../") == "http://example.com/" |
| 532 | assert url.join("../../g") == "http://example.com/g" |
| 533 | |
| 534 | assert url.join("../../../g") == "http://example.com/g" |
| 535 | assert url.join("../../../../g") == "http://example.com/g" |
| 536 | |
| 537 | assert url.join("/./g") == "http://example.com/g" |
| 538 | assert url.join("/../g") == "http://example.com/g" |
| 539 | assert url.join("g.") == "http://example.com/b/c/g." |
| 540 | assert url.join(".g") == "http://example.com/b/c/.g" |
| 541 | assert url.join("g..") == "http://example.com/b/c/g.." |
| 542 | assert url.join("..g") == "http://example.com/b/c/..g" |
| 543 | |
| 544 | assert url.join("./../g") == "http://example.com/b/g" |
| 545 | assert url.join("./g/.") == "http://example.com/b/c/g/" |
| 546 | assert url.join("g/./h") == "http://example.com/b/c/g/h" |
| 547 | assert url.join("g/../h") == "http://example.com/b/c/h" |
| 548 | assert url.join("g;x=1/./y") == "http://example.com/b/c/g;x=1/y" |
| 549 | assert url.join("g;x=1/../y") == "http://example.com/b/c/y" |
| 550 | |
| 551 | assert url.join("g?y/./x") == "http://example.com/b/c/g?y/./x" |
| 552 | assert url.join("g?y/../x") == "http://example.com/b/c/g?y/../x" |
| 553 | assert url.join("g#s/./x") == "http://example.com/b/c/g#s/./x" |
| 554 | assert url.join("g#s/../x") == "http://example.com/b/c/g#s/../x" |
| 555 | |
| 556 | |
| 557 | def test_resolution_error_1833(): |