Skip to content

Implement URI for pure Wasm#2

Open
lostflydev wants to merge 1 commit intoscala-wasmfrom
fix/151-uri-normalize-wasm
Open

Implement URI for pure Wasm#2
lostflydev wants to merge 1 commit intoscala-wasmfrom
fix/151-uri-normalize-wasm

Conversation

@lostflydev
Copy link
Owner

@lostflydev lostflydev commented Mar 9, 2026

Summary

Make java.net.URI fully compatible with the pure Wasm backend by providing linkTimeIf branches for all JS-dependent operations.

Closes scala-wasm#153

Changes

  • URI parsing: new parseURI() abstraction returns Array[String] instead of js.RegExp.ExecResult; uses java.util.regex.Pattern on Wasm
  • normalize(): separate normalizeJS() (js.Array with mutating ops) and normalizePureWasm() (Scala Array + System.arraycopy + StringBuilder)
  • IPv6 detection: testIPv6() uses java.util.regex on Wasm
  • Quoting functions (userInfo, path, authority, illegal, nonASCII): extract regex strings into *ReStr vals; new quoteWithPattern() and quoteStrFn() for Wasm using java.util.regex + UTF-8 percent-encoding
  • Build.scala: enable URITest and ClassValueTest in Wasm test suite filter
  • Tests: 6 new tests for constructor quoting, IPv6 hosts, normalize edge cases, relative paths with colons, toString round-trips, and non-ASCII percent-encoding

@lostflydev lostflydev force-pushed the fix/151-uri-normalize-wasm branch from 00ab0b9 to 9ad1162 Compare March 9, 2026 11:09
Add linkTimeIf branches for all JS-dependent operations in URI:
- URI parsing: js.RegExp.exec() → java.util.regex.Pattern
- Path normalization: js.Array + .join() → Scala Array + StringBuilder
- IPv6 detection: js.RegExp.test() → java.util.regex.Pattern
- Quoting (5 functions): jsReplace(regex, callback) → quoteWithPattern()
- UTF-8 percent-encoding: pure Scala via StandardCharsets.UTF_8

Remove top-level vals with JS types (RegExp, js.Function1) to avoid
linker errors; inline them into linkTimeIf JS branches instead.

Unblock URITest in pure Wasm test suite. Add 6 new tests covering
multi-component quoting, IPv6, normalize edge cases, and non-ASCII.
@lostflydev lostflydev force-pushed the fix/151-uri-normalize-wasm branch from 6f7a29d to 915b509 Compare March 10, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support fixed length list type in Component Model

1 participant