fix leading period before two-element extensions

This commit is contained in:
Joey Hess 2012-07-06 17:22:56 -06:00
parent 2c4b39be4f
commit 8ad844e45c

View file

@ -102,9 +102,13 @@ keyValueE size source = keyValue size source >>= maybe (return Nothing) addE
}
selectExtension :: FilePath -> String
selectExtension = join "." . reverse . take 2 . takeWhile shortenough .
reverse . split "." . takeExtensions
selectExtension f
| null es = ""
| otherwise = join "." ("":es)
where
es = filter (not . null) $ reverse $
take 2 $ takeWhile shortenough $
reverse $ split "." $ takeExtensions f
shortenough e
| '\n' `elem` e = False -- newline in extension?!
| otherwise = length e <= 4 -- long enough for "jpeg"