From 61d10bcbc6eab6fdfab316532ffd6c685191518e Mon Sep 17 00:00:00 2001 From: bom Date: Thu, 6 Jul 2023 14:09:22 +0200 Subject: [PATCH] Check if the input is String before regex match --- .../domaindrivenarchitecture/activity_pub_poc/core.clj | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/core.clj b/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/core.clj index 2a4b39d..b41b2c3 100644 --- a/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/core.clj +++ b/src/main/clj/org/domaindrivenarchitecture/activity_pub_poc/core.clj @@ -27,13 +27,16 @@ (def parsed-rdf-syntax (parse (slurp cm/activitystreams-ttl))) (defn type-string? [input] - (re-matches #"[A-Z]" (str (first input)))) + (and (string? input) + (re-matches #"[A-Z]" (str (first input))))) (defn url-string? [input] - (re-matches #"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)" input)) + (and (string? input) + (re-matches #"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)" input))) (defn uri-string? [input] - (re-matches #"\w+:(\/?\/?)[^\s]+" input)) + (and (string? input) + (re-matches #"\w+:(\/?\/?)[^\s]+" input))) (defn uri-vector? [input] (and (every? #(uri-string? %) input)