summaryrefslogtreecommitdiff
path: root/Backend
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-07-06 17:22:56 -0600
committerGravatar Joey Hess <joey@kitenet.net>2012-07-06 17:22:56 -0600
commit8ad844e45c3f8a65ef5b725e9c6ac0f414b50fa4 (patch)
treedf3ade67917f01f8abfc89a1e85662ceddbf225b /Backend
parent2c4b39be4f68b53c2d2bc3647b17789b316fc542 (diff)
fix leading period before two-element extensions
Diffstat (limited to 'Backend')
-rw-r--r--Backend/SHA.hs8
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"