diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index acf96f18..9b5ce432 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,6 +3,7 @@ on: push: branches: - main + - v3 pull_request: permissions: contents: read diff --git a/CHANGELOG.md b/CHANGELOG.md index e99b68fc..e0592eb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). * Removed Node.js 10 and Node.js 12 support. * Reduced npm package size. +## 3.3.8 +* Fixed a way to brake Nano ID by passing non-integer size (by @myndzi). + ## 3.3.7 * Fixed `node16` TypeScript support (by Saadi Myftija). diff --git a/index.browser.js b/index.browser.js index 4e242791..896369b4 100644 --- a/index.browser.js +++ b/index.browser.js @@ -36,7 +36,7 @@ export let customRandom = (alphabet, defaultSize, getRandom) => { while (true) { let bytes = getRandom(step) // A compact alternative for `for (var i = 0; i < step; i++)`. - let j = step + let j = step | 0 while (j--) { // Adding `|| ''` refuses a random byte that exceeds the alphabet size. id += alphabet[bytes[j] & mask] || ''