Skip to content

Fix non-integer size in customRandom() - #616

Merged
ai merged 1 commit into
ai:mainfrom
lost-signals:fix-non-integer-size
Oct 5, 2026
Merged

ai merged 1 commit into
ai:mainfrom
lost-signals:fix-non-integer-size

Conversation

@lost-signals

Copy link
Copy Markdown
Contributor

Since 5.1.8, customRandom() returns alphabet[0] repeated for a non-integer size on power-of-two alphabets, e.g. customAlphabet('0123456789abcdef')(16.5) gives "00000000000000000" in the browser build. This truncates size before the loop and adds tests.

Adds 4 B to customAlphabet, so I bumped the limit to 223 B.

@ai
ai merged commit 0b2cec5 into ai:main Oct 5, 2026
4 checks passed
bayandin added a commit to bayandin/nanoid that referenced this pull request Oct 6, 2026
Co-authored-by: L0stS1gnals <nhm7226@g.rit.edu>
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.

3 participants