fix(isISBN): accept empty options when checking both versions - #2882
fix(isISBN): accept empty options when checking both versions#2882a3ylf wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2882 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 114 114
Lines 2599 2600 +1
Branches 658 658
=========================================
+ Hits 2599 2600 +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.
Validated exact head 797b78e858d6a156651e623eff15da73e4564b35 against base a79ff980ab14257e795332989e497bdff3218e87.
Applying the PR test file to unchanged base reproduces three failures (empty options, undefined version, null version); the top-level null compatibility control passes. Head full npm test passes 327 tests with generated builds and ESLint on Node 24.15.0. All 13 exposed upstream checks pass.
I also checked 1,406 ISBN-shaped/malformed strings across 16 option cases on each of source, Node, browser, and minified browser: 22,496 observations per form. The option-dispatch oracle is the unchanged base explicit ISBN-10/13 results (their OR for the documented default), so this isolates option handling rather than claiming a new ISBN grammar oracle. Base has 1,204 mismatches per form; head has zero. Explicit numeric/string versions, legacy calls, invalid explicit versions, formatting controls, and checksum mutations are included.
This resolves the documented missing-version default without changing the checked explicit-version behavior.
Passing an empty options object to
isISBNrejects valid ISBN-10 and ISBN-13 values. For example,isISBN('340101319X', {})returnsfalse, while omitting the second argument returnstrue. The README says both versions are checked when no version is provided.Read
versionfrom options objects before applying the legacy version-argument handling. Empty options and an undefined or nullversionnow use the documented default. Explicit versions and the legacy numeric/string arguments retain their behavior.Validation on Node.js 24.15.0:
npm testpassed: 327 tests, including builds and ESLint; 100% statement, function, and line coverage.nulloptions covers all six conditions on the options-handling line.git diff --checkpassed.The README already describes the expected behavior, so it needs no change. This is an independently reproduced bug; I found no existing matching issue or pull request.
Checklist