Repository navigation
fix: accept uppercase spellings of the standard option - #403
Open
rahul05ranjan wants to merge 1 commit into
Open
rahul05ranjan wants to merge 1 commit into
rahul05ranjan wants to merge 1 commit into
Conversation
The JSDoc for the `standard` option advertises "SI, IEC, JEDEC", but
STANDARD_CONFIGS is keyed on lowercase "si"/"iec"/"jedec", so any
uppercase spelling missed the lookup and silently fell through to the
decimal default:
filesize(1048576, { standard: "iec" }) // "1 MiB"
filesize(1048576, { standard: "IEC" }) // "1.05 MB" (wrong unit system)
Case-normalize the value in getBaseConfiguration() before the lookup.
Unknown values keep the existing fallback behavior (pinned by the
"should fall back to JEDEC default for unknown standard" test).
Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The JSDoc for the
standardoption advertises"SI, IEC, JEDEC", but theSTANDARD_CONFIGSlookup is keyed on the lowercase"si"/"iec"/"jedec", so an uppercase spelling misses the lookup and silently falls through to the decimal default — the wrong unit system:Fix
Case-normalize the value in
getBaseConfiguration()before the cached lookup. Unknown values keep the existing fallback behavior, which is pinned by theshould fall back to JEDEC default for unknown standardtest, so this change only affects spellings that are case variants of the three real standards — exactly the ones the JSDoc shows. The same normalization coverspartial({ standard: "IEC" }).Verification
tests/unit/filesize.test.js(uppercaseIEC/JEDEC/SI, thepartial()path, and a guard that the unknown-value fallback is unchanged): 3 fail onmain@d2bb4c1, all pass with this change.node --test tests/unit/— 278 pass, 0 fail (273 pre-existing + 5 new).