ring 2025-03-12

Why the special character in the url is not accepted by ring

below is my ring code

(ns ring-app.core
  (:require [ring.adapter.jetty :as jetty]
            [ring.middleware.params :refer [wrap-params]]
            [clojure.pprint :refer [pprint]]))

(defn handler [request-map]
  (println "got a request to process ...")
  (pprint request-map)
  {:status 200
   :headers {"Content-Type" "application/json"}
   :body (get (:query-params request-map) "phone")})

(defn -main []
  (println "starting handler...")
  (jetty/run-jetty

   (-> handler
       wrap-params)

   {:port 3000 :join? false}))

Any idea why + is not parsed correctly?

This is my GET request in curl

It returns 653215 6789

Because + is the standard URL encoding for space in HTTP URLs. %2b would the be encoding for +. If you're generating the link, you need to URLEncode it.

☝️ 1