Re: [whatwg/url] Add Unicode ToASCII fallback for ASCII domains (PR #914)

rmisev left a comment (whatwg/url#914)

> Just checking, and sorry if I'm being/have been annoying/weird, but does and should this provide an equivalent fallback for Domain to Unicode?

I think so, we need a fallback. If we don't do this, we may end up in a situation where `domain to ASCII` succeeds, but `domain to Unicode` returns an invalid or altered domain. For example:
1. Changes domain:
   ```js
   domain_to_ASCII("xn--8i7caa.famitei.net", false) // xn--8i7caa.famitei.net
   domain_to_ASCII(domain_to_Unicode("xn--8i7caa.famitei.net", false), false) // www.famitei.net
   ```
2. Returns an invalid domain:
   ```js
   domain_to_ASCII("xn--board-ngr.org", false) // xn--board-ngr.org
   domain_to_ASCII(domain_to_Unicode("xn--board-ngr.org", false), false) // Failure
   ```
To solve this problem, I would suggest changing the second step of `domain to Unicode` as follows:

2. Signify domain-to-Unicode validation errors for any returned errors. If an error is returned, *beStrict* is `false`, and *domain* is an ASCII string, return the lowercased *domain*. Otherwise, return *result*.

A few examples:
*domain* | `domain to Unicode` (current) | `domain to Unicode` (proposed)
-|-|-
`xn--8i7caa.famitei.net` | `www.famitei.net` | `xn--8i7caa.famitei.net`
`xn--board-ngr.org` | `ิboard.org` | `xn--board-ngr.org`
`XN--0.XN--NXA` | `xn--0.β` | `xn--0.xn--nxa`
`XN--0.ABC` | `xn--0.abc` | `xn--0.abc`
`XN--ABC-` | `abc` | `xn--abc-`


-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/pull/914#issuecomment-4759608002
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/url/pull/914/c4759608002@github.com>

Received on Saturday, 20 June 2026 18:39:29 UTC