• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aio-libs / yarl / 36971974712
98%

Build:
DEFAULT BRANCH: master
Ran 02 Oct 2026 06:08AM UTC
Jobs 1
Files 49
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

01 Oct 2026 08:03PM UTC coverage: 97.803% (+0.05%) from 97.752%
36971974712

push

github

web-flow
Drop localhost from file URLs in WHATWG mode (#1961)

<!-- Thank you for your contribution! -->

## What do these changes do?

In WHATWG mode a `file` URL now follows the WHATWG file host state: the
`localhost` host (in any case, also once percent-decoded or IDNA-mapped)
becomes the empty host, and a `file` URL with userinfo or a port is
rejected. `file://localhost/test` is `file:///test`, `file://localhost`
is `file:///`, and `file://example:1/` fails. RFC 3986 mode is
unchanged.

Parsing, `URL.build()`, `join()`, `with_host()`, `with_scheme()`,
`with_port()`, `with_user()`, `with_password()` and a change of mode all
apply the same rule, so a built or joined URL matches the parsed one. A
Windows drive letter authority such as `file://C:/` is not treated as a
port; drive letters are left for a follow-up.

All 10 rows of the "file host that WHATWG rewrites" category move from
"WHATWG mode differs from WHATWG, RFC mode follows RFC 3986+3987" to
"yarl follows each standard in its mode" (264 -> 274):
`file://example:1/`, `file://localhost`, `file://localhost/`,
`file://localhost/test`, `file:\\localhost//`,
`file://localhost//a//../..//`, `\/localhost//pig` and
`//localhost//pig` against `file://lion/`,
`file://localhost//a//../..//foo` and `file://localhost////foo`. In
addition, `file://loC𝐀𝐋𝐇𝐨𝐬𝐭/usr/bin` ("non-ASCII or percent-encoded
host") moves from "Both modes differ from their standard" to "RFC mode
differs from RFC 3986+3987, WHATWG mode follows WHATWG", since its
WHATWG leg is now right. "yarl differs, RFC 3986+3987 and WHATWG agree"
stays at 0 rows.

## Are there changes in behavior for the user?

Yes. In the default WHATWG mode `URL("file://localhost/p")` is now
`URL("file:///p")`, and a `file` URL with userinfo or a port raises
`ValueError`. RFC mode and `encoded=True` parsing keep both as before.

## Is it a substantial burden for the maintainers to support this?

No. The rule lives in one check helper plus the existing host moving
helper (`_... (continued)

97 of 194 branches covered (50.0%)

Branch coverage included in aggregate %.

295 of 296 new or added lines in 2 files covered. (99.66%)

10095 of 10227 relevant lines covered (98.71%)

0.99 hits per line

Uncovered Changes

Lines Coverage ∆ File
1
99.51
tests/test_url_file_host.py
Jobs
ID Job ID Ran Files Coverage
1 MyPy - 36971974712.1 02 Oct 2026 06:08AM UTC 49
97.8
GitHub Action Run
Source Files on build 36971974712
  • Tree
  • List 49
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #36971974712
  • db820bb2 on github
  • Prev Build on master (#36882483374)
  • Next Build on master (#37000909309)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc