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

@domenic approved this pull request.

This looks good to me, modulo some wording suggestions.

Two more options for your consideration, both based around trying to make the "beStrict vs. not-beStrict" divergence more obvious (since non-validating parsers only ever implement beStrict = false):

---

1. Let _result_ be null.
1. If _beStrict_ is true:
    1. Set _result_ to the result of running Unicode ToASCII with ...
    1. If _result_ is a failure value, domain-to-ASCII validation error, return failure.
1. Otherwise:
    1. If _domain_ is an ASCII string:
        1. If running Unicode ToASCII with ..., domain-to-ASCII validation error.
        1. Set _result_ to _domain_, lowercased.
    1. Otherwise:
        1. Set _result_ to the result of running Unicode ToASCII with ...
        1. If _result_ is a failure value, domain-to-ASCII validation error, return failure.
    1. If _result_ is the empty string, domain-to-ASCII validation error, return failure.
    1. If _result_ contains a forbidden domain code point, domain-invalid-code-point validation error, return failure.
1. Assert: result is not the empty string and does not contain a forbidden domain code point.
1. Return _result_.

---

1. If _beStrict_ is true:
    1. Let _result_ be the result of running Unicode ToASCII with ...
    1. If _result_ is a failure value, domain-to-ASCII validation error, return failure.
    1. Return _result_.
1. Let _result_ be null.
1. If _domain_ is an ASCII string:
    1. If running Unicode ToASCII with ..., domain-to-ASCII validation error.
    1. Set _result_ to _domain_, lowercased.
1. Otherwise:
    1. Set _result_ to the result of running Unicode ToASCII with ...
    1. If _result_ is a failure value, domain-to-ASCII validation error, return failure.
1. If _result_ is the empty string, domain-to-ASCII validation error, return failure.
1. If _result_ contains a forbidden domain code point, domain-invalid-code-point validation error, return failure.
1. Return _result_.

(drops the assert in the beStrict case)


> +  <p class=note>Due to web compatibility <a abstract-op lt=ToASCII>Unicode ToASCII</a> only records
+  <a>validation errors</a> when <var>domain</var> is an <a>ASCII string</a>.

```suggestion
  <p class=note>In the non-strict branch, due to web compatibility, <a abstract-op lt=ToASCII>Unicode ToASCII</a> failures only result in
  <a>validation errors</a> (instead of failing the whole algorithm) when <var>domain</var> is an <a>ASCII string</a>.
```

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

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

Received on Friday, 12 June 2026 05:42:32 UTC