make gemQuery field of GemURL optional (with Maybe)

This commit is contained in:
2021-10-24 18:54:41 -04:00
parent a2d8f1a5ea
commit a5d0c25fc3
3 changed files with 10 additions and 7 deletions

View File

@@ -53,8 +53,8 @@ encodeGemURL url =
Nothing -> ""
path = intercalate "/" $ map escapeString $ gemPath url
query = case gemQuery url of
"" -> ""
q -> '?' : escapeString q
Nothing -> ""
Just q -> '?' : escapeString q
-- | add required escape sequences to a string
escapeString :: String -> String

View File

@@ -39,8 +39,8 @@ data GemURL = GemURL
-- ^ The port number (if supplied)
, gemPath :: [String]
-- ^ The decoded path segments
, gemQuery :: String
-- ^ The decoded request query
, gemQuery :: Maybe String
-- ^ The decoded request query (if supplied)
} deriving (Eq, Show)
-- | Builds a new 'GemURL'
@@ -52,7 +52,7 @@ newGemURL host = GemURL
{ gemHost = host
, gemPort = Nothing
, gemPath = []
, gemQuery = ""
, gemQuery = Nothing
}
--jl