From 54c30533425d4e9f05851df2bfbf316de80c7c56 Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Sun, 14 May 2017 20:35:32 +0300 Subject: [PATCH] Escape segments in linkURI --- servant/src/Servant/Utils/Links.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/servant/src/Servant/Utils/Links.hs b/servant/src/Servant/Utils/Links.hs index fb847c15..0318f96c 100644 --- a/servant/src/Servant/Utils/Links.hs +++ b/servant/src/Servant/Utils/Links.hs @@ -164,6 +164,10 @@ addQueryParam qp l = -- >>> linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) [1, 2, 3] -- sum?x[]=1&x[]=2&x[]=3 -- +-- >>> type API = "foo/bar" :> Get '[JSON] Int +-- >>> linkURI $ safeLink (Proxy :: Proxy API) (Proxy :: Proxy API) +-- foo%2Fbar +-- linkURI :: Link -> URI linkURI = linkURI' LinkArrayElementBracket @@ -186,7 +190,7 @@ linkURI' :: LinkArrayElementStyle -> Link -> URI linkURI' addBrackets (Link segments q_params) = URI mempty -- No scheme (relative) Nothing -- Or authority (relative) - (intercalate "/" segments) + (intercalate "/" $ map escape segments) (makeQueries q_params) mempty where makeQueries :: [Param] -> String