ring

RAJKUMAR 2025-03-12T18:23:17.004089Z

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

RAJKUMAR 2025-03-12T18:23:33.944789Z

below is my ring code

RAJKUMAR 2025-03-12T18:23:39.129809Z

(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}))

RAJKUMAR 2025-03-12T18:25:07.050609Z

Any idea why + is not parsed correctly?

RAJKUMAR 2025-03-12T18:25:46.943189Z

This is my GET request in curl

RAJKUMAR 2025-03-12T18:25:48.824669Z

curl ''

RAJKUMAR 2025-03-12T18:27:01.449139Z

It returns 653215 6789

RAJKUMAR 2025-03-12T18:27:09.695879Z

Any idea?

seancorfield 2025-03-12T19:11:19.134619Z

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
RAJKUMAR 2025-03-12T23:52:50.192859Z

Thanks @seancorfield