diff --git a/CHANGELOG.md b/CHANGELOG.md index a310a2ff..54972334 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v1.41.1 (23 Jul 2024) + +* fix: randomId size over 21 error [#33](https://github.com/liriliri/licia/issues/33) + ## v1.41.0 (18 Jun 2024) * feat: add dataUrl diff --git a/lib/update.js b/lib/update.js index 0e993fb0..e6460edd 100644 --- a/lib/update.js +++ b/lib/update.js @@ -10,7 +10,6 @@ const { map, contain, sortKeys, - escape, filter, concat, unique diff --git a/package.json b/package.json index 130dccdb..f2534f7a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "licia", - "version": "1.41.0", + "version": "1.41.1", "description": "Useful utility collection with zero dependencies", "bin": { "licia": "./bin/licia.js" diff --git a/src/randomId.js b/src/randomId.js index 6a168398..b408c2f7 100644 --- a/src/randomId.js +++ b/src/randomId.js @@ -30,7 +30,7 @@ exports = function(size = 21, symbols = defSymbols) { let id = ''; const len = symbols.length; - const bytes = randomBytes(21); + const bytes = randomBytes(size); while (0 < size--) { id += symbols[bytes[size] % len]; } diff --git a/test/randomId.js b/test/randomId.js index 8913c67c..1125d488 100644 --- a/test/randomId.js +++ b/test/randomId.js @@ -2,3 +2,4 @@ expect(randomId()).to.be.a('string'); expect(randomId().length).to.equal(21); expect(randomId(12).length).to.equal(12); expect(randomId(5, 'a')).to.equal('aaaaa'); +expect(randomId(22, 'a')).to.equal('aaaaaaaaaaaaaaaaaaaaaa');