fetchItem: improved mime type guessing.
Strip a fragment like `?#iefix` from the extension before doing the mime lookup.
This commit is contained in:
parent
1d137fbed6
commit
85ff3c5771
1 changed files with 5 additions and 4 deletions
|
@ -775,12 +775,13 @@ fetchItem sourceURL s =
|
|||
Nothing -> openURL s' -- will throw error
|
||||
(Nothing, _) -> E.try readLocalFile -- get from local file system
|
||||
where readLocalFile = do
|
||||
let mime = case takeExtension s of
|
||||
".gz" -> getMimeType $ dropExtension s
|
||||
x -> getMimeType x
|
||||
cont <- BS.readFile $ unEscapeString $ dropFragmentAndQuery s
|
||||
cont <- BS.readFile fp
|
||||
return (cont, mime)
|
||||
dropFragmentAndQuery = takeWhile (\c -> c /= '?' && c /= '#')
|
||||
fp = unEscapeString $ dropFragmentAndQuery s
|
||||
mime = case takeExtension fp of
|
||||
".gz" -> getMimeType $ dropExtension fp
|
||||
x -> getMimeType x
|
||||
ensureEscaped = escapeURIString isAllowedInURI
|
||||
|
||||
-- | Like 'fetchItem', but also looks for items in a 'MediaBag'.
|
||||
|
|
Loading…
Add table
Reference in a new issue