From: Ramakrishnan Muthukrishnan Date: Sun, 15 Feb 2015 10:17:32 +0000 (+0530) Subject: refactor urlEncode X-Git-Url: https://git.rkrishnan.org/uri/%22doc.html/frontends/provisioning?a=commitdiff_plain;h=fd9add6b09082b1805683235ded659ddf5fc77b2;p=functorrent.git refactor urlEncode --- 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)