summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Hakyll/Core/Store.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Hakyll/Core/Store.hs b/lib/Hakyll/Core/Store.hs
index fdbcf11..cb17218 100644
--- a/lib/Hakyll/Core/Store.hs
+++ b/lib/Hakyll/Core/Store.hs
@@ -27,6 +27,7 @@ import Data.Maybe (isJust)
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import Data.Typeable (TypeRep, Typeable, cast, typeOf)
+import Numeric (showHex)
import System.Directory (createDirectoryIfMissing)
import System.Directory (doesFileExist, removeFile)
import System.FilePath ((</>))
@@ -193,5 +194,8 @@ deleteFile = handle (\(_ :: IOException) -> return ()) . removeFile
--------------------------------------------------------------------------------
-- | Mostly meant for internal usage
hash :: [String] -> String
-hash = concatMap (printf "%02x") . B.unpack .
- MD5.hash . T.encodeUtf8 . T.pack . intercalate "/"
+hash = toHex . B.unpack . MD5.hash . T.encodeUtf8 . T.pack . intercalate "/"
+ where
+ toHex [] = ""
+ toHex (x : xs) | x < 16 = '0' : showHex x (toHex xs)
+ | otherwise = showHex x (toHex xs)