git.iko.soy/typeable/pandoc
on master help sign in
fetchItem: improved mime type guessing.
85ff3c5John MacFarlane
src/Text/Pandoc/Shared.hs+5−4
@@ -775,12 +775,13 @@ fetchItem sourceURL s =
775 Nothing -> openURL s' -- will throw error
775 Nothing -> openURL s' -- will throw error
776 (Nothing, _) -> E.try readLocalFile -- get from local file system
776 (Nothing, _) -> E.try readLocalFile -- get from local file system
777 where readLocalFile = do
777 where readLocalFile = do
778− let mime = case takeExtension s of
779− ".gz" -> getMimeType $ dropExtension s
780− x -> getMimeType x
781− cont <- BS.readFile $ unEscapeString $ dropFragmentAndQuery s
778+ cont <- BS.readFile fp
782 return (cont, mime)
779 return (cont, mime)
783 dropFragmentAndQuery = takeWhile (\c -> c /= '?' && c /= '#')
780 dropFragmentAndQuery = takeWhile (\c -> c /= '?' && c /= '#')
781+ fp = unEscapeString $ dropFragmentAndQuery s
782+ mime = case takeExtension fp of
783+ ".gz" -> getMimeType $ dropExtension fp
784+ x -> getMimeType x
784 ensureEscaped = escapeURIString isAllowedInURI
785 ensureEscaped = escapeURIString isAllowedInURI
785
786
786-- | Like 'fetchItem', but also looks for items in a 'MediaBag'.
787-- | Like 'fetchItem', but also looks for items in a 'MediaBag'.