Remove use of unsafe decodeUtf8

This commit is contained in:
2020-04-17 09:30:45 +02:00
parent 6c1ae585b7
commit 9d9e415a09
7 changed files with 40 additions and 31 deletions

View File

@@ -44,7 +44,7 @@ deriveJSON defaultOptions { fieldLabelModifier = removeLensFieldLabel } ''Requir
instance ToJSON URI where
toJSON = toJSON . decodeUtf8 . serializeURIRef'
toJSON = toJSON . decUTF8Safe . serializeURIRef'
instance FromJSON URI where
parseJSON = withText "URL" $ \t ->
@@ -151,7 +151,7 @@ instance FromJSONKey Tool where
instance ToJSON (Path Rel) where
toJSON p = case and . fmap isAscii . BS.unpack $ fp of
True -> toJSON . E.decodeUtf8 $ fp
True -> toJSON . decUTF8Safe $ fp
False -> String "/not/a/valid/path"
where fp = toFilePath p