git.iko.soy/typeable/http-api-data
on master help sign in
Escape reserved symbols in default implementation of toEncodedUrlPiece
c80fefaVladislav
src/Web/Internal/HttpApiData.hs+2−4
unifiedsplit
@@ -96,7 +96,7 @@ class ToHttpApiData a where
96 -- The default definition uses 'H.encodePathSegmentsRelative',
96 -- The default definition uses 'H.encodePathSegmentsRelative',
97 -- but this may be overriden with a more efficient version.
97 -- but this may be overriden with a more efficient version.
98 toEncodedUrlPiece :: a -> BS.Builder
98 toEncodedUrlPiece :: a -> BS.Builder
99− toEncodedUrlPiece = H.encodePathSegmentsRelative . (:[]) . toUrlPiece
99+ toEncodedUrlPiece = H.urlEncodeBuilder True . encodeUtf8 . toUrlPiece
100
100
101 -- | Convert to HTTP header value.
101 -- | Convert to HTTP header value.
102 toHeader :: a -> ByteString
102 toHeader :: a -> ByteString
@@ -514,7 +514,7 @@ instance ToHttpApiData DayOfWeek where
514
514
515 toEncodedUrlPiece = unsafeToEncodedUrlPiece
515 toEncodedUrlPiece = unsafeToEncodedUrlPiece
516
516
517−-- |
517+-- |
518-- >>> toUrlPiece Q4
518-- >>> toUrlPiece Q4
519-- "q4"
519-- "q4"
520instance ToHttpApiData QuarterOfYear where
520instance ToHttpApiData QuarterOfYear where
@@ -865,5 +865,3 @@ runAtto :: Atto.Parser a -> Text -> Either Text a
865runAtto p t = case Atto.parseOnly (p <* Atto.endOfInput) t of
865runAtto p t = case Atto.parseOnly (p <* Atto.endOfInput) t of
866 Left err -> Left (T.pack err)
866 Left err -> Left (T.pack err)
867 Right x -> Right x
867 Right x -> Right x
868−
869−