3 ms·
Odd design decision in that if you provide your own blocklist, it overwrites their (extensive) default list instead of adding to it. And in general the algorit
by dumbo-octopus 3y ago
Odd design decision in that if you provide your own blocklist, it overwrites their (extensive) default list instead of adding to it.
And in general the algorithm is surprisingly complicated for something that could be replaced with simply base64 encoding, the given example (1,2,3) base64 encodes to a string with just one more letter than this algorithm.
That said I do appreciate the semicolon-free-style. I don't typically see that in libs besides my own.
https://github.com/sqids/sqids-javascript/blob/main/src/sqids.ts https://github.com/sqids/sqids-javascript/blob/main/src/sqid...
- 8organicbits 3y agoThe problem is their block list will change over time. If you don't override it, then your IDs won't decode right when you update. This is a huge risk. > You have to account for scenarios where a new word might be introduced to the default blocklist https://sqids.org/faq#future-blocklist https://sqids.org/faq#future-blocklist Honestly, I think they need to rethink this. Otherwise you've got different library versions for different languages each using different default blocklists, none of which are compatible.
- wtetzner 3y ago> If you don't override it, then your IDs won't decode right when you update. They'll decode fine. Encoding might change.
- 8organicbits 3y agoI think your right, but that violates the uniqueness guarantee. It doesnt seem like something that should change over time by default.
- dumbo-octopus 3y agoThere explicitly is no uniqueness guarantee. It is known that the same values can encode into many different strings, and they recommend always decoding then reencoding with a stable algorithm to achieve a "canonical" id if one is needed. https://sqids.org/faq#valid-ids https://sqids.org/faq#valid-ids