aboutsummaryrefslogtreecommitdiff
path: root/test/js/web/web-globals.test.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-07-11 19:14:34 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-11 19:14:34 -0700
commitcbb88672f217a90db1aa1eb29cd92d5d9035b22b (patch)
tree43a00501f3cde495967e116f0b660777051551f8 /test/js/web/web-globals.test.js
parent1f900cff453700b19bca2acadfe26da4468c1282 (diff)
parent34b0e7a2bbd8bf8097341cdb0075d0908283e834 (diff)
downloadbun-jarred/esm-conditions.tar.gz
bun-jarred/esm-conditions.tar.zst
bun-jarred/esm-conditions.zip
Merge branch 'main' into jarred/esm-conditionsjarred/esm-conditions
Diffstat (limited to 'test/js/web/web-globals.test.js')
-rw-r--r--test/js/web/web-globals.test.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/js/web/web-globals.test.js b/test/js/web/web-globals.test.js
index b7a243190..d687a1290 100644
--- a/test/js/web/web-globals.test.js
+++ b/test/js/web/web-globals.test.js
@@ -138,6 +138,25 @@ it("crypto.randomUUID", () => {
});
});
+it("crypto.randomUUID version, issues#3575", () => {
+ var uuid = crypto.randomUUID();
+
+ function validate(uuid) {
+ const regex =
+ /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
+ return typeof uuid === "string" && regex.test(uuid);
+ }
+ function version(uuid) {
+ if (!validate(uuid)) {
+ throw TypeError("Invalid UUID");
+ }
+
+ return parseInt(uuid.slice(14, 15), 16);
+ }
+
+ expect(version(uuid)).toBe(4);
+});
+
it("URL.prototype.origin", () => {
const url = new URL("https://html.spec.whatwg.org/");
const { origin, host, hostname } = url;