mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Simplify the getUuid
helper function
We can remove most feature testing from this helper function, with the exception of `randomUUID` since that's only available in "secure contexts", and also remove the fallback code-path. Note that this code was only added for Node.js compatibility, and it's no longer necessary now that the minimum support version is `20`; see also https://developer.mozilla.org/en-US/docs/Web/API/Crypto#browser_compatibility Finally, this patch also adds a basic unit-test for the helper function.
This commit is contained in:
parent
07765e993e
commit
c290a12ce1
2 changed files with 11 additions and 11 deletions
|
@ -18,6 +18,7 @@ import {
|
|||
bytesToString,
|
||||
createValidAbsoluteUrl,
|
||||
getModificationDate,
|
||||
getUuid,
|
||||
string32,
|
||||
stringToBytes,
|
||||
stringToPDFString,
|
||||
|
@ -248,4 +249,12 @@ describe("util", function () {
|
|||
expect(getModificationDate(date)).toEqual("31410609020653");
|
||||
});
|
||||
});
|
||||
|
||||
describe("getUuid", function () {
|
||||
it("should get uuid string", function () {
|
||||
const uuid = getUuid();
|
||||
expect(typeof uuid).toEqual("string");
|
||||
expect(uuid.length).toBeGreaterThanOrEqual(32);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue