Fork me on GitHub
#cljs-dev
<
2022-04-08
>
Adam Kalisz09:04:27

@quoll @dnolen (def ^:private uuid-regex #"^[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]-[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]-[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]-[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]-[0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z][0-9a-zA-Z]$") matches way more than just a valid uuid, just try to replace some digit with a x for instance. Just use this instead perhaps?

(def ^:private uuid-regex
  "Regex matching to a UUID in hexadecimal form, e.g., 0713d2bf-8e70-41e2-8b81-c8ca3ef4a8cd."
  #"^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[4][0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}$")

Adam Kalisz09:04:44

That would be for UUIDv4, the general form would be this:

(def ^:private uuid-regex
  "Regex matching to a UUID in hexadecimal form, e.g., 0713d2bf-8e70-41e2-8b81-c8ca3ef4a8cd."
  #"^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$")

dnolen13:04:11

hrm ok, I didn't actually check the Clojure side, what regex is used there?

Alex Miller (Clojure team)13:04:23

clojure just calls into java.util.UUID

quoll13:04:25

This was totally a mistake on my part and definitely needs fixing, yes! (And why all my code needs reviewing)

quoll13:04:47

Hmm, I know I worked on several regexes with this, and thought I ended on a simpler one. Maybe I checked the wrong one in? Unfortunately, I can't check right now, because I have to use a different computer for work