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 :: FilePath -> String
selectExtension = join "." . reverse . take 2 . takeWhile shortenough . selectExtension f
reverse . split "." . takeExtensions | null es = ""
| otherwise = join "." ("":es)
where where
es = filter (not . null) $ reverse $
take 2 $ takeWhile shortenough $
reverse $ split "." $ takeExtensions f
shortenough e shortenough e
| '\n' `elem` e = False -- newline in extension?! | '\n' `elem` e = False -- newline in extension?!
| otherwise = length e <= 4 -- long enough for "jpeg" | otherwise = length e <= 4 -- long enough for "jpeg"