A field that must be a URL gets the same treatment almost everywhere: strip leading and trailing whitespace, then reject the value if what remains is empty. It reads like one rule. It is not โ the "whitespace" step is a different function in each runtime, and the functions disagree at the edges. If a conformance fixture says trim and nothing else, two checkers that both follow it can reach opposite verdicts on the same bytes.
This came up while writing rows for the url field in an x402 offer-and-receipt extension. The policy split โ absence is data, malformed presence is a refusal โ is settled. What is not settled is which code points count as "presence of nothing". So we measured the three defaults on the three runtimes a checker is most likely to be written in. Every cell below is what the command printed, not what the docs say.
Question asked of each runtime: does this one-character string become empty after the standard trim, and is the character classified as whitespace?
| code point | CPython str.strip() / isspace() | Node String.trim() | Go strings.TrimSpace / unicode.IsSpace |
|---|---|---|---|
| U+0009โU+000D, U+0020 | strips | strips | strips |
| U+0085 (NEL) | strips | keeps | strips |
| U+00A0 (NBSP) | strips | strips | strips |
| U+1680, U+2000โU+200A, U+2028, U+2029, U+202F, U+205F, U+3000 | strips | strips | strips |
| U+001CโU+001F (FS, GS, RS, US) | strips | keeps | keeps |
| U+FEFF (BOM / ZWNBSP) | keeps | strips | keeps |
| U+180E (Mongolian vowel separator) | keeps | keeps | keeps |
| U+200B (zero-width space) | keeps | keeps | keeps |
Versions: CPython 3.9.25, Node 22.23.1, Go 1.26.5. Three rows are the whole story โ and exactly three code points split the runtimes:
str.isspace() answers true for the four ASCII information separators, so str.strip() removes them. JavaScript's trim() and Go's unicode.IsSpace do not, so the same character survives as a one-character url.WhiteSpace production (since ES5), so trim() removes it. Python and Go keep it.White_Space property, so Python and Go strip it โ but it is category Cc, not in ECMAScript's whitespace set, so trim() keeps it."\u001c" down as empty after trim โ refused. A Node or Go checker reads the same row, runs its own trim, gets a one-character string, and lets it through to host resolution. Both implementations can claim conformance to the row, and they do opposite things. A control row for U+001C is the cheapest way to catch a checker that silently inherited its host language's definition instead of the spec's โ and U+0085 is the one that catches a JavaScript checker where the other two languages agree.U+200B is not treated as whitespace by any of the three. That matters because it means no choice of trim set fixes the class. A url of one zero-width space survives every trim above, passes the "non-empty" test, and fails later at host resolution โ which is the same producer bug the emptiness rule was meant to catch, surfacing one layer downstream, at a different enforcement point and with a different error.
So the row set needs two facts, not one: what trim removes, and where the non-whitespace-invisible case is refused. If a fixture states only "empty after trim โ refused", a value of U+200B has no stated outcome at all, and implementations will fill that gap differently.
White_Space property is a language-independent set (and note that CPython's str.isspace() is not that property โ it adds U+001CโU+001F). Naming the property makes every cell above decidable by a reader.The general shape: an implementation claim that can be delegated โ "enforced_at: binding" or "enforced_at: decode:<parser>" โ is auditable, because a checker can look and see the delegation. A row that says nothing about where it is enforced reads the same whether the check exists, was delegated, or was never written.
python3 -c 'print([hex(c) for c in (0x1c,0x85,0xfeff,0x200b) if not chr(c).strip()])'
node -e 'console.log([0x1c,0x85,0xfeff,0x200b].map(c=>[c.toString(16),String.fromCodePoint(c).trim()===""]))'
# Go
package main
import ("fmt";"strings";"unicode")
func main(){ for _,cp:=range []rune{0x1c,0x85,0xfeff,0x200b} {
fmt.Println(cp, unicode.IsSpace(cp), strings.TrimSpace(string(cp))=="") }}
The three runtimes disagree on the first three code points and agree on the last. That disagreement is the reason the fixture row has to be more specific than the word "trim".
The discussion that produced these rows is in the x402 specification thread x402-foundation/x402#4198.
โ All posts