|
990 | 990 | "hostname": "test",
|
991 | 991 | "port": "12"
|
992 | 992 | }
|
| 993 | + }, |
| 994 | + { |
| 995 | + "comment": "Leading / is not stripped", |
| 996 | + "href": "http://example.com/", |
| 997 | + "new_value": "///bad.com", |
| 998 | + "expected": { |
| 999 | + "href": "http://example.com/", |
| 1000 | + "host": "example.com", |
| 1001 | + "hostname": "example.com" |
| 1002 | + } |
| 1003 | + }, |
| 1004 | + { |
| 1005 | + "comment": "Leading / is not stripped", |
| 1006 | + "href": "sc://example.com/", |
| 1007 | + "new_value": "///bad.com", |
| 1008 | + "expected": { |
| 1009 | + "href": "sc:///", |
| 1010 | + "host": "", |
| 1011 | + "hostname": "" |
| 1012 | + } |
993 | 1013 | }
|
994 | 1014 | ],
|
995 | 1015 | "hostname": [
|
|
1345 | 1365 | "hostname": "",
|
1346 | 1366 | "pathname": "//p"
|
1347 | 1367 | }
|
| 1368 | + }, |
| 1369 | + { |
| 1370 | + "comment": "Leading / is not stripped", |
| 1371 | + "href": "http://example.com/", |
| 1372 | + "new_value": "///bad.com", |
| 1373 | + "expected": { |
| 1374 | + "href": "http://example.com/", |
| 1375 | + "host": "example.com", |
| 1376 | + "hostname": "example.com" |
| 1377 | + } |
| 1378 | + }, |
| 1379 | + { |
| 1380 | + "comment": "Leading / is not stripped", |
| 1381 | + "href": "sc://example.com/", |
| 1382 | + "new_value": "///bad.com", |
| 1383 | + "expected": { |
| 1384 | + "href": "sc:///", |
| 1385 | + "host": "", |
| 1386 | + "hostname": "" |
| 1387 | + } |
1348 | 1388 | }
|
1349 | 1389 | ],
|
1350 | 1390 | "port": [
|
|
1571 | 1611 |
|
1572 | 1612 | }
|
1573 | 1613 | },
|
| 1614 | + { |
| 1615 | + "comment": "Special URLs cannot have their paths erased", |
| 1616 | + "href": "file:///some/path", |
| 1617 | + "new_value": "", |
| 1618 | + "expected": { |
| 1619 | + "href": "file:///", |
| 1620 | + "pathname": "/" |
| 1621 | + } |
| 1622 | + }, |
| 1623 | + { |
| 1624 | + "comment": "Non-special URLs can have their paths erased", |
| 1625 | + "href": "foo://somehost/some/path", |
| 1626 | + "new_value": "", |
| 1627 | + "expected": { |
| 1628 | + "href": "foo://somehost", |
| 1629 | + "pathname": "" |
| 1630 | + } |
| 1631 | + }, |
| 1632 | + { |
| 1633 | + "comment": "Non-special URLs with an empty host can have their paths erased", |
| 1634 | + "href": "foo:///some/path", |
| 1635 | + "new_value": "", |
| 1636 | + "expected": { |
| 1637 | + "href": "foo://", |
| 1638 | + "pathname": "" |
| 1639 | + } |
| 1640 | + }, |
| 1641 | + { |
| 1642 | + "comment": "Path-only URLs cannot have their paths erased", |
| 1643 | + "href": "foo:/some/path", |
| 1644 | + "new_value": "", |
| 1645 | + "expected": { |
| 1646 | + "href": "foo:/", |
| 1647 | + "pathname": "/" |
| 1648 | + } |
| 1649 | + }, |
| 1650 | + { |
| 1651 | + "comment": "Path-only URLs always have an initial slash", |
| 1652 | + "href": "foo:/some/path", |
| 1653 | + "new_value": "test", |
| 1654 | + "expected": { |
| 1655 | + "href": "foo:/test", |
| 1656 | + "pathname": "/test" |
| 1657 | + } |
| 1658 | + }, |
1574 | 1659 | {
|
1575 | 1660 | "href": "unix:/run/foo.socket?timeout=10",
|
1576 | 1661 | "new_value": "/var/log/../run/bar.socket",
|
|
1667 | 1752 | "pathname": "/%23"
|
1668 | 1753 | }
|
1669 | 1754 | },
|
| 1755 | + { |
| 1756 | + "comment": "? doesn't mess up encoding", |
| 1757 | + "href": "http://example.net", |
| 1758 | + "new_value": "/?é", |
| 1759 | + "expected": { |
| 1760 | + "href": "http://example.net/%3F%C3%A9", |
| 1761 | + "pathname": "/%3F%C3%A9" |
| 1762 | + } |
| 1763 | + }, |
| 1764 | + { |
| 1765 | + "comment": "# doesn't mess up encoding", |
| 1766 | + "href": "http://example.net", |
| 1767 | + "new_value": "/#é", |
| 1768 | + "expected": { |
| 1769 | + "href": "http://example.net/%23%C3%A9", |
| 1770 | + "pathname": "/%23%C3%A9" |
| 1771 | + } |
| 1772 | + }, |
1670 | 1773 | {
|
1671 | 1774 | "comment": "File URLs and (back)slashes",
|
1672 | 1775 | "href": "file://monkey/",
|
|
0 commit comments