git.iko.soy/typeable/http-api-data
on master help sign in
Escape reserved symbols in default implementation of toEncodedUrlPiece
commitc80fefa3d69847b9afa00755206add0f6c29d946 authorVladislav <vlad.lagunoff@gmail.com> dateTue 19 Jul 2022, 18:04 (4 years ago) parentd2573ce
1 file changed+2−4
unifiedsplit
src/Web/Internal/HttpApiData.hs+2−4
src/Web/Internal/HttpApiData.hs+2−4
@@ -96,7 +96,7 @@ class ToHttpApiData a where
9696 -- The default definition uses 'H.encodePathSegmentsRelative',
9797 -- but this may be overriden with a more efficient version.
9898 toEncodedUrlPiece :: a -> BS.Builder
99− toEncodedUrlPiece = H.encodePathSegmentsRelative . (:[]) . toUrlPiece
99+ toEncodedUrlPiece = H.urlEncodeBuilder True . encodeUtf8 . toUrlPiece
100100
101101 -- | Convert to HTTP header value.
102102 toHeader :: a -> ByteString
@@ -514,7 +514,7 @@ instance ToHttpApiData DayOfWeek where
514514
515515 toEncodedUrlPiece = unsafeToEncodedUrlPiece
516516
517−-- |
517+-- |
518518-- >>> toUrlPiece Q4
519519-- "q4"
520520instance ToHttpApiData QuarterOfYear where
@@ -865,5 +865,3 @@ runAtto :: Atto.Parser a -> Text -> Either Text a
865865runAtto p t = case Atto.parseOnly (p <* Atto.endOfInput) t of
866866 Left err -> Left (T.pack err)
867867 Right x -> Right x
868−
869−