Skip to content

Commit

Permalink
joinr's fix broke parsing urls with schemes not registered with the jvm.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnuernber committed Aug 3, 2021
1 parent 5d863ee commit 0d8a04a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/tech/v3/io/url.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@


(defn maybe-url [^String url]
(try (java.net.URL. url) (catch Exception e nil)))
(re-find #"[A-Za-z0-9]+:\/\/" url)
;;Leaving here to make a point. The below fails for any url
;;that doesn't have a scheme registered with the central java url
;;system - such as s3 or azb.
#_(try (java.net.URL. url)
(catch Exception e nil)))


(defn parse-url-arguments
Expand Down
6 changes: 6 additions & 0 deletions test/tech/v3/io/url_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
(is (not (nil? (url/url->parts "s3://a/b/c"))))
(is (not (nil? (url/url->parts "makeitup://a/b/c")))))


(deftest valid-url-test
(is (url/url? "s3://a/b/c"))
(is (url/url? "https://a/b/c"))
(is (not (url/url? "C:\\\\Users\\\\joinr\\\\data\\\\yellow_tripdata_2016-01.csv"))))

(deftest windows-paths-are-not-urls
(let [p "C:\\Users\\joinr\\data\\yellow_tripdata_2016-01.csv"]
(is (not (boolean (url/url? p))))))

0 comments on commit 0d8a04a

Please sign in to comment.