Skip to content

Commit

Permalink
Updated parse-scheme-specific to correctly separate authority, path, …
Browse files Browse the repository at this point in the history
…and query.
  • Loading branch information
wtetzner committed Feb 5, 2011
1 parent b7ceb4e commit 3f4b0da
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/org/bovinegenius/uri/parser.clj
@@ -1,4 +1,5 @@
(ns org.bovinegenius.uri.parser)
(ns org.bovinegenius.uri.parser
(:require (clojure [string :as str])))

(defn parse-generic
"Takes a URI string and parses it into scheme, scheme-specific-part,
Expand All @@ -15,8 +16,12 @@ and fragment parts."
parts."
[ssp]
(if ssp
(let [[_ authority path query] (re-find #"^//(.*?(?=\.\.|\./|/))([^\?]+)\??(.*)$" ssp)
query (if (.contains ssp "?") query nil)]
(let [[front & query] (str/split ssp #"\?")
query (reduce str query)
query (if (.contains ssp "?") query nil)
auth-path (last (re-find #"^//(.*)$" front))
[_ authority path] (re-find #"^(.*?)(?=\./|\.\./|/|$)(.*)" auth-path)
path (if (empty? path) nil path the )]
{:authority authority :path path :query query})
{:authority nil :path nil :query nil}))

Expand Down

0 comments on commit 3f4b0da

Please sign in to comment.