sqids / sqids-javascript

Official JavaScript port of Sqids. Generate short unique IDs from numbers.
https://sqids.org/javascript
MIT License
679 stars 14 forks source link

Blocklist doesn't work as expected #30

Open yokrysty opened 3 weeks ago

yokrysty commented 3 weeks ago

i created a minimal example: 1234567 generates 56thj, but if i choose to block thj i expect to have another id and this does not happen i tracked the problem to be in function isBlockedId at the first comparison: if i change

if (lowercaseId.length <= 3 || word.length <= 3) {

to

if (lowercaseId.length === word.length) {

it works as expected, because it will go on the other conditions

example

const sqids = new Sqids({
    blocklist: new Set(['thj'])
});
const id = sqids.encode([1234567]); // 56thj
console.log(id);