From cc7b3f38f47f3eb7dee956f13ed9a80800cc0b9b Mon Sep 17 00:00:00 2001 From: gered Date: Wed, 3 Sep 2014 08:49:23 -0400 Subject: [PATCH] helper function for checking if a url is absolute or not --- src/clj_hl7_fhir/core.clj | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/clj_hl7_fhir/core.clj b/src/clj_hl7_fhir/core.clj index 23e2b0c..7280d06 100644 --- a/src/clj_hl7_fhir/core.clj +++ b/src/clj_hl7_fhir/core.clj @@ -257,6 +257,18 @@ (url) (.toString)))) +(defn absolute-url? + "returns true if the passed URL is an absolute URL, false if not. if the value + passed in is not a string (or an empty string) an exception is thrown." + [^String resource-url] + (if (and (string? resource-url) + (not (str/blank? resource-url))) + (boolean + (try + (url resource-url) + (catch Exception ex))) + (throw (new Exception "Invalid URL or non-string value.")))) + (defn collect-resources "returns a sequence containing all of the resources contained in the given bundle. deleted resources listed in the bundle will not be included in the returned