Open micolous opened 7 months ago
While this is based on #886, I've marked it as "ready for review", as this isn't really a work in progress – it's just blocked.
All modified and coverable lines are covered by tests :white_check_mark:
:exclamation: No coverage uploaded for pull request base (
main@a4dd58b
). Click here to learn what that means.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
This pull request is based on #886. Merging this PR will also merge #886.
This removes the dependency on
idna
onwasm32-unknown-unknown
, replacing it with a small shim which calls out toweb_sys::Url
.With a small
yew
demo app (which callsUrl::parse()
), this reduces binary size by 228 KiB on a release build and by 425 KiB on a debug build. These savings should go a lot of the way towards addressing #557, while retaining IDN support.API changes
The deprecations could be split out from this, I've included them as related work.
Deprecate
quirks::domain_to_unicode()
: https://github.com/whatwg/url/issues/63Removed on
wasm32-unknown-unknown
because browsers never implemented it.Deprecate
Origin::unicode_serialization()
: #881Removed on
wasm32-unknown-unknown
because it requiresdomain_to_unicode
.Deprecate
quirks::domain_to_ascii()
: https://github.com/whatwg/url/issues/63Kept on
wasm32-unknown-unknown
, because its implementation does not depend on browser functionality.Alternatives considered
Downstream libraries could adopt
web_sys::Url
onwasm32-unknown-unknown
.This is API-breaking, and complicated to handle, for reasons I've covered in #557 and https://github.com/seanmonstar/reqwest/issues/2050.
There are similar pains discussed in https://github.com/sagebind/isahc/issues/382 for a
http::Uri
tourl::Url
migration.Shimming out every single piece of functionality to JavaScript's
Url
type (viaweb_sys::Url
) onwasm32-unknown-unknown
.This would probably make things smaller again, but there are enough subtle API differences to make this a problem. For example,
url::Url::host()
returns aurl::Host
, butweb_sys::Url::hostname()
returns aString
.Shimming in
idna
.Not all the functionality required is supported in web APIs (
domain_to_unicode
), and so it needs changes toUrl
anyway.This also allows one to continue using the
idna
crate directly onwasm32-unknown-unknown
with its normalisation database.Known issues
There are a few extra test failures (see
expected_failures_{chromium,firefox,safari}.txt
) – I'm not certain which of these are browser bugs orurl::Host
bugs.In any case, I don't think I can fix them, and I don't know how much one should care.
I haven't tried this on
redox
orwasi
targets – they don't appear to be covered by CI, and so I've left them as-is.It may be possible to get similar binary size savings on those targets, but I'm keeping them out of scope for now.