fix(isLatLong): reject extra coordinate components - #2880
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2880 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 114 114
Lines 2599 2598 -1
Branches 658 658
=========================================
- Hits 2599 2598 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
nrps9909
left a comment
There was a problem hiding this comment.
Verified exact head fd05da79e532eb787809a0c71071b2fda8364906 against base a79ff980ab14257e795332989e497bdff3218e87.
Both new tests fail on the unchanged base for the reported reason: decimal and DMS pairs with a trailing comma are accepted. The head passes the complete npm test workflow: build, lint and 325 tests on Node 24.15.0. All 13 currently reported upstream checks pass.
An independent 2,450-case corpus was run against each of source, Node, browser and minified-browser builds. It covers decimal range boundaries, signs, spaces, parentheses, extra empty/numeric/text components, canonical DMS pairs, missing commas and non-string argument errors. Each base form has 1,310 false accepts; all four head forms have zero mismatches in this corpus (9,800 head observations total). The reference expectations are constructed from the selected numeric ranges and known valid DMS pairs, not copied from the implementation regexes.
The exact-two-component guard matches the documented pair format and leaves the existing range/format expressions unchanged. Approval is scoped to rejecting extra components; this is not a claim of exhaustive DMS or geographic-format conformance. Both review worktrees are restored clean. AI-assisted review with independently executed validation.
isLatLongsplits the input on commas but validates only the first two components, soisLatLong('0,0,garbage')and a valid DMS pair followed by,garbagereturntrue.Require exactly two components before validating them. This rejects trailing commas and additional numeric or text fields in both decimal and DMS modes, matching the documented
lat,long/lat, longformat. Existing coordinate ranges, parentheses and formatting checks remain unchanged.Reference: documented isLatLong format. I checked related open and closed PRs; #1074 handles parentheses and #1340 adds DMS support, but neither checks for extra components. The open test reorganization in #2698 does not fix this behavior.
Validation on Node.js 24.19.0:
npm testpasses: 325 tests, including build and lint.git diff --checkpasses.This change was prepared and independently reviewed with Codex; the checks above were run locally.
Checklist