Move the internationalized domain name code from JsonValidator.kt into
a new internal object Idna in Idna.kt: isValidHostname,
isValidIdnHostname, the UTS 46 mapping (idnaMap, isIdnaIgnored), the
U-label checks, the RFC 5892 contextual rules, the RFC 5893 Bidi rule,
RFC 3492 Punycode, and the tables and constants only they use
(IDNA_*, KATAKANA_MIDDLE_DOT_SCRIPTS, CURSIVE_SCRIPTS,
VIRAMA_CODE_POINTS, BIDI_*, PUNYCODE_*, ACE_PREFIX, label and hostname
length limits, ZWJ/ZWNJ, REGEX_HOSTNAME_LABEL).
- DDD: IDNA is a subdomain of its own (RFC 3492, 5890-5893), with
nothing JSON Schema specific in it.
- SRP: its tables change with Unicode versions, not with JSON Schema
semantics.
- DRY: hostname, idn-hostname, email and idn-email all call the same
two entry points, Idna.isValidHostname() and Idna.isValidIdnHostname();
everything else in the object stays private.
Function bodies and comments are unchanged; only qualification and
visibility changed. Behaviour is unchanged and the public API is
untouched. JsonValidator.kt goes from 2,662 to 2,222 lines.
Closes #94
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Summary
Moves the IDNA code out of
JsonValidator.ktinto a newinternal object Idnainsrc/main/kotlin/org/ktson/Idna.kt. Nothing else changes.isValidHostname,isValidIdnHostname,idnaMap,isIdnaIgnored,isValidULabel,isAllowedIdnCodePoint, the RFC 5892 contextual rules (satisfiesContextualRules,isJoiningContext,isJoiningTransparent,isJoiningLetter,isVirama), the RFC 5893 Bidi rule (isRtlCodePoint,satisfiesBidiRule) and RFC 3492 Punycode (punycodeDecode,punycodeEncode,punycodeAdapt,punycodeDigit,punycodeChar).IDNA_*,KATAKANA_MIDDLE_DOT_SCRIPTS,CURSIVE_SCRIPTS,VIRAMA_CODE_POINTS,BIDI_*,PUNYCODE_*,ACE_PREFIX,MAX_LABEL_LENGTH,MAX_HOSTNAME_LENGTH,ZWJ/ZWNJandREGEX_HOSTNAME_LABEL.Idna.isValidHostname()andIdna.isValidIdnHostname()are visible outside the object.validateFormat,isValidEmailDomainandisValidIdnEmailcall them. Everything else staysprivate.JsonValidator.ktgoes from 2,662 to 2,222 lines, andIdna.kthas 449.Idna.kt. The Architecture lines inmemory/MEMORY.mdare updated. There is no CHANGELOG entry because the refactor is internal.Verification
./gradlew ktlintFormatCI=true ./gradlew test ktlintCheck --rerun-tasks: BUILD SUCCESSFUL, with the official suite required.build/test-results/test/*.xmlreports 5,849 tests, 0 failures, 0 errors, 0 skipped, the same count as before.python3 .claude/skills/fix-issue/scripts/test_counts.py: exit 0 (full run 5,849, custom 1,379).Closes #94
🤖 Generated with Claude Code