Skip to content

refactor: tidy parser file layout and inline redundant NFC wrapper#50

Merged
OmarAlJarrah merged 1 commit into
mainfrom
refactor/parser-idna-housekeeping
Jul 8, 2026
Merged

refactor: tidy parser file layout and inline redundant NFC wrapper#50
OmarAlJarrah merged 1 commit into
mainfrom
refactor/parser-idna-housekeeping

Conversation

@OmarAlJarrah

Copy link
Copy Markdown
Member

What

Three small housekeeping cleanups in the parser and idna packages.

  • FILE_SCHEME constant was declared private const val FILE_SCHEME = "file" in three separate parser files.
  • UrlParserDrive.kt held only three internal Windows-drive predicates, in the same package as UrlParserHelpers.kt — which already consumes them.
  • Idna.normalizeNfc was a one-line pass-through to Normalizer.nfc.

Change

  • Consolidate the three parser copies of FILE_SCHEME into one internal const in UrlParserHelpers. Url.kt keeps its own copy — it's in a different package, and importing a parser-internal const there for a single literal would read worse than the local const (and SpecialScheme.FILE is an enum property, not a compile-time constant, so it's no cleaner for hot-path string comparisons).
  • Fold the three drive predicates into UrlParserHelpers beside their consumers and delete UrlParserDrive.kt. Same package + same internal signatures, so callers are unchanged. UrlParserHelpers gains a @file:Suppress("TooManyFunctions"), matching the existing precedent for deliberate helper files.
  • Inline normalizeNfc to Normalizer.nfc at both call sites, preserving the "UTS-46 step 3" rationale as a comment and fixing a now-dangling KDoc link.

Safety

Pure refactor — no behavior change, public API unchanged (apiCheck passes with no apiDump). Verified on the JVM gate + a Kotlin/Native macosArm64 compile.


Stacked on #49.

Housekeeping in the parser and idna packages:

  - Collapse three per-file copies of `private const val FILE_SCHEME = "file"`
    in the parser package into one internal const in UrlParserHelpers. (Url.kt's
    own copy stays: it is in a different package, and importing a parser-internal
    const there for one literal would read worse than the local one.)
  - Fold UrlParserDrive's three Windows-drive predicates into UrlParserHelpers,
    which already consumes them, and delete the file. One flat bag of
    same-package helper predicates does not need two files.
  - Inline Idna's one-line normalizeNfc pass-through to Normalizer.nfc at both
    call sites, keeping the "UTS-46 step 3" rationale as a comment.

Pure refactor: no behavior change, public API unchanged.
@OmarAlJarrah OmarAlJarrah force-pushed the refactor/parser-idna-housekeeping branch from 77c554a to 29fb632 Compare July 8, 2026 11:30
@OmarAlJarrah OmarAlJarrah changed the base branch from refactor/host-percent-query-cleanups to main July 8, 2026 11:30
@OmarAlJarrah OmarAlJarrah merged commit 06ef9d5 into main Jul 8, 2026
11 of 20 checks passed
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.

1 participant