From 2a8e17fb05c9bf538e3e606457a09734f8c99037 Mon Sep 17 00:00:00 2001 From: Gary Fredericks Date: Wed, 4 Nov 2015 08:55:12 -0600 Subject: [PATCH] Generate larger range of random UUIDs The random-uuid function was only generating hex characters from 0-e, but should be using 0-f. Adjusted the arg to the first rand-int call to make this work, and adjusted the second one as well, which should have no effect on the behavior but is less confusing to read. --- src/main/cljs/cljs/core.cljs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/cljs/cljs/core.cljs b/src/main/cljs/cljs/core.cljs index f6d624fcb5..0dc6b0d4cf 100644 --- a/src/main/cljs/cljs/core.cljs +++ b/src/main/cljs/cljs/core.cljs @@ -9861,8 +9861,8 @@ Maps become Objects. Arbitrary keys are encoded to by key->js." (UUID. s nil)) (defn random-uuid [] - (letfn [(hex [] (.toString (rand-int 15) 16))] - (let [rhex (.toString (bit-or 0x8 (bit-and 0x3 (rand-int 14))) 16)] + (letfn [(hex [] (.toString (rand-int 16) 16))] + (let [rhex (.toString (bit-or 0x8 (bit-and 0x3 (rand-int 16))) 16)] (uuid (str (hex) (hex) (hex) (hex) (hex) (hex) (hex) (hex) "-"