module GigSpider.URL where

import Data.List
import Network.URI

joinTuple :: String -> (String, String) -> String
joinTuple sep (a, b) = a ++ sep ++ b

urlWithParams :: String -> [(String, String)] -> String
urlWithParams url params =
  escapeURIString isAllowedInURI withParams
  where
    withParams = url ++ "?" ++ joinedParams
    joinedParams = intercalate "&" . map (joinTuple "=") $ params
