From fd9add6b09082b1805683235ded659ddf5fc77b2 Mon Sep 17 00:00:00 2001
From: Ramakrishnan Muthukrishnan <ram@rkrishnan.org>
Date: Sun, 15 Feb 2015 15:47:32 +0530
Subject: [PATCH] refactor urlEncode

---
 src/Tracker.hs | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/Tracker.hs b/src/Tracker.hs
index 75c3a00..51877d7 100644
--- a/src/Tracker.hs
+++ b/src/Tracker.hs
@@ -22,15 +22,12 @@ urlEncode bs = concatMap (encode . BC.unpack) (splitN 2 bs)
                                   in
                                    escape c c1 c2
         encode _ = ""
-        escape i c1 c2 | isAsciiUpper i ||
-                         isAsciiLower i ||
-                         isDigit i ||
-                         i == '-' ||
-                         i == '_' ||
-                         i == '.' ||
-                         i == '~'
-                         = [i]
+        escape i c1 c2 | i `elem` nonSpecialChars = [i]
                        | otherwise = "%" ++ [c1] ++ [c2]
+          where nonSpecialChars = ['A'..'Z'] ++
+                                  ['a'..'z'] ++
+                                  ['0'..'9'] ++
+                                  ['-', '_', '.', '~']
 
 -- (chr . read . ("0x" ++) . BC.unpack)
 -- connect :: Url -> String -> IO (Benc.BVal)
-- 
2.45.2