diff options
Diffstat (limited to 'Backend/SHA.hs')
-rw-r--r-- | Backend/SHA.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Backend/SHA.hs b/Backend/SHA.hs index 95ce4a770..cf61139e0 100644 --- a/Backend/SHA.hs +++ b/Backend/SHA.hs @@ -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" |