summaryrefslogtreecommitdiff
path: root/src/Data/Torrent/InfoHash.hs
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2013-11-25 09:29:50 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2013-11-25 09:29:50 +0400
commit119fc02eae541b45817de6945c1029e6dc53c17b (patch)
tree84a1ba5e6391b6ed8c1a07c6001813d89a613560 /src/Data/Torrent/InfoHash.hs
parent90eb078137b81135473bc96359ebd44577267a19 (diff)
Fix warning in textToInfoHash function
Diffstat (limited to 'src/Data/Torrent/InfoHash.hs')
-rw-r--r--src/Data/Torrent/InfoHash.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Data/Torrent/InfoHash.hs b/src/Data/Torrent/InfoHash.hs
index e15fdbb3..3d2bbe25 100644
--- a/src/Data/Torrent/InfoHash.hs
+++ b/src/Data/Torrent/InfoHash.hs
@@ -22,6 +22,7 @@ module Data.Torrent.InfoHash
22 22
23 , addHashToURI 23 , addHashToURI
24 24
25 -- * Internal
25 , Data.Torrent.InfoHash.hash 26 , Data.Torrent.InfoHash.hash
26 , Data.Torrent.InfoHash.hashlazy 27 , Data.Torrent.InfoHash.hashlazy
27 ) where 28 ) where
@@ -111,7 +112,7 @@ instance Pretty InfoHash where
111 112
112-- | Tries both base16 and base32 while decoding info hash. 113-- | Tries both base16 and base32 while decoding info hash.
113textToInfoHash :: Text -> Maybe InfoHash 114textToInfoHash :: Text -> Maybe InfoHash
114textToInfoHash text 115textToInfoHash t
115 | hashLen == 32 = Just $ InfoHash $ Base32.decode hashStr 116 | hashLen == 32 = Just $ InfoHash $ Base32.decode hashStr
116 | hashLen == 40 = let (ihStr, inv) = Base16.decode hashStr 117 | hashLen == 40 = let (ihStr, inv) = Base16.decode hashStr
117 in if BS.length inv == 0 118 in if BS.length inv == 0
@@ -120,7 +121,7 @@ textToInfoHash text
120 | otherwise = Nothing 121 | otherwise = Nothing
121 where 122 where
122 hashLen = BS.length hashStr 123 hashLen = BS.length hashStr
123 hashStr = T.encodeUtf8 text 124 hashStr = T.encodeUtf8 t
124 125
125-- | Hex encode infohash to text, full length. 126-- | Hex encode infohash to text, full length.
126longHex :: InfoHash -> Text 127longHex :: InfoHash -> Text