(ns ^{:go-imports ["net/url"]
      :doc "Parses URLs and implements query escaping."}
  url)

(defn ^String path-escape
  "Escapes the string so it can be safely placed inside a URL path segment."
  {:added "1.0"
   :go "url.PathEscape(s)"}
  [^String s])

(defn ^String path-unescape
  "Does the inverse transformation of path-escape, converting each 3-byte encoded
  substring of the form \"%AB\" into the hex-decoded byte 0xAB. It also converts
  '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits.

  PathUnescape is identical to QueryUnescape except that it does not unescape '+' to ' ' (space)."
  {:added "1.0"
   :go "pathUnescape(s)"}
  [^String s])

(defn ^String query-escape
  "Escapes the string so it can be safely placed inside a URL query."
  {:added "1.0"
   :go "url.QueryEscape(s)"}
  [^String s])

(defn ^String query-unescape
  "Does the inverse transformation of query-escape, converting each 3-byte encoded
  substring of the form \"%AB\" into the hex-decoded byte 0xAB. It also converts
  '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits."
  {:added "1.0"
   :go "queryUnescape(s)"}
  [^String s])

(defn parse-query
  "Parses the URL-encoded query string and returns a map listing the vectors of values specified for each key.
  Always returns a non-nil map containing all the valid query parameters found.
  Query is expected to be a list of key=value settings separated by ampersands. A setting without
  an equals sign is interpreted as a key set to an empty value. Settings containing a non-URL-encoded
  semicolon are considered invalid. "
  {:added "1.3.6"
   :go "parseQuery(s)"}
  [^String s])
