Skip to content

Reject codes with a trailing newline - #135

Merged
alcohol merged 1 commit into
mainfrom
fix-guard-trailing-newline
Nov 2, 2026
Merged

alcohol merged 1 commit into
mainfrom
fix-guard-trailing-newline

Conversation

@alcohol

@alcohol alcohol commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Guards anchored its format regexes with $, which in PCRE also matches just before a final newline. So alpha2("NL\n"), alpha3("NLD\n") and numeric("528\n") passed the format check and then threw OutOfBoundsException (not found) instead of DomainException (invalid format).

The patterns now end in \z. There are new data-provider cases for each method; they fail without the fix.

Name handling (the guard trims, the lookup doesn't) is unchanged here. It's covered by the 5.0 design.

🤖 Generated with Claude Code

In PCRE, `$` also matches before a final newline, so "NL\n" passed the
alpha2 format check and surfaced as OutOfBoundsException (not found)
instead of DomainException (invalid). Anchor with \z instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.69%. Comparing base (27599cb) to head (dcd30e3).

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #135   +/-   ##
=========================================
  Coverage     95.69%   95.69%           
  Complexity       46       46           
=========================================
  Files             4        4           
  Lines            93       93           
=========================================
  Hits             89       89           
  Misses            4        4           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alcohol
alcohol merged commit 54ce88a into main Nov 2, 2026
10 checks passed
@alcohol
alcohol deleted the fix-guard-trailing-newline branch November 2, 2026 15:23
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.

2 participants