-
-
Notifications
You must be signed in to change notification settings - Fork 822
Permalink
Choose a base ref
{{ refName }}
default
Choose a head ref
{{ refName }}
default
Comparing changes
Choose two branches to see what’s changed or to start a new pull request.
If you need to, you can also or
learn more about diff comparisons.
Open a pull request
Create a new pull request by comparing changes across two branches. If you need to, you can also .
Learn more about diff comparisons here.
base repository: ai/nanoid
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3.3.7
Could not load branches
Nothing to show
Loading
Could not load tags
Nothing to show
{{ refName }}
default
Loading
...
head repository: ai/nanoid
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3.3.11
Could not load branches
Nothing to show
Loading
Could not load tags
Nothing to show
{{ refName }}
default
Loading
- 11 commits
- 29 files changed
- 2 contributors
Commits on Nov 26, 2024
-
Fix pool pollution, infinite loop (#510)
* Fix pool pollution, infinite loop When nanoid is called with a fractional value, there were a number of undesirable effects: - in browser and non-secure, the code infinite loops on `while (size--)` - in node, the value of poolOffset becomes fractional, causing calls to nanoid to return zeroes until the pool is next filled: when `i` is initialized to `poolOffset`, `pool[i] & 63` -> `undefined & 63` -> `0` - if the first call in node is a fractional argument, the initial buffer allocation fails with an error I chose `|0` to cast to a signed integer primarily because that has a slightly better outcome in the third case above: if the first call is negative (e.g. `nanoid(-1)`) then Node will throw an error for an invalid Buffer size, rather than attempting to allocate a buffer of size `2**32-1`. It's also more compact than `>>>0`, which would be necessary to cast to an unsigned integer. I don't _think_ there is a use case for generating ids longer than `2**31-1` :) The browser code is structured in such a way that casting `size` in `customRandom` succinctly isn't readily feasible. I chose to cast it at the line `let j = step | 0` since casting defaultSize would not fix the infinite loop in all cases, and the other use of defaultSize is to define the step length which is already shown to be fractional and gets cast to an integer with `~` anyway. As for the `nanoid` function, `new Uint8Array(size)` ignores the fractional part, and `size` doesn't get used further - the function instead calls reduce over the typed array. In the Node/native async customAlphabet variant, I chose to convert the `id.length === size` check to `id.length >= size`, which handles the fractional case and avoids the infinite loop; `size` is not used for anything else there. * `const` -> `let`
Configuration menu - View commit details
-
Copy full SHA for d643045 - Browse repository at this point
Copy the full SHA d643045View commit details -
Configuration menu - View commit details
-
Copy full SHA for 4fe3495 - Browse repository at this point
Copy the full SHA 4fe3495View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3044cd5 - Browse repository at this point
Copy the full SHA 3044cd5View commit details
Commits on Mar 7, 2025
-
Configuration menu - View commit details
-
Copy full SHA for 1c6f088 - Browse repository at this point
Copy the full SHA 1c6f088View commit details -
Configuration menu - View commit details
-
Copy full SHA for adf9b0c - Browse repository at this point
Copy the full SHA adf9b0cView commit details
Commits on Mar 15, 2025
-
Configuration menu - View commit details
-
Copy full SHA for 8f44264 - Browse repository at this point
Copy the full SHA 8f44264View commit details -
Configuration menu - View commit details
-
Copy full SHA for bb12e8a - Browse repository at this point
Copy the full SHA bb12e8aView commit details
Commits on Mar 18, 2025
-
Configuration menu - View commit details
-
Copy full SHA for a83734e - Browse repository at this point
Copy the full SHA a83734eView commit details -
Configuration menu - View commit details
-
Copy full SHA for c147962 - Browse repository at this point
Copy the full SHA c147962View commit details -
Configuration menu - View commit details
-
Copy full SHA for 23690b7 - Browse repository at this point
Copy the full SHA 23690b7View commit details -
Configuration menu - View commit details
-
Copy full SHA for 37289ce - Browse repository at this point
Copy the full SHA 37289ceView commit details
Loading
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff 3.3.7...3.3.11