Safe Haskell | None |
---|---|
Language | Haskell2010 |
Note: this library parses, but does not validate urls
Synopsis
- data Url
- data ParseError
- decodeUrl :: Bytes -> Either ParseError Url
- getScheme :: Url -> Maybe Bytes
- getUsername :: Url -> Maybe Bytes
- getAuthority :: Url -> Maybe Bytes
- getPassword :: Url -> Maybe Bytes
- getHost :: Url -> Maybe Bytes
- getPath :: Url -> Maybe Bytes
- getQuery :: Url -> Maybe Bytes
- getFragment :: Url -> Maybe Bytes
- getExtension :: Url -> Maybe Bytes
- getPort :: Url -> Maybe Word16
- constructUrl :: Maybe String -> String -> Maybe Word16 -> String -> [(String, String)] -> Maybe String -> Q (TExp Url)
- literalUrl :: String -> Q (TExp Url)
Types
Url type represented by its serialization, and slices of that serialization.
Syntax in pseudo-BNF:
url = scheme ":" [ hierarchical | non-hierarchical ] [ "?" query ]? [ "#" fragment ]? non-hierarchical = non-hierarchical-path non-hierarchical-path = * Does not start with "" */ hierarchical = authority? hierarchical-path authority = "//" userinfo? host [ ":" port ]? userinfo = username [ ":" password ]? "@" hierarchical-path = [ "/" path-segment ]+
data ParseError Source #
Possible parse errors
Instances
Eq ParseError Source # | |
Defined in Url.Unsafe (==) :: ParseError -> ParseError -> Bool # (/=) :: ParseError -> ParseError -> Bool # | |
Ord ParseError Source # | |
Defined in Url.Unsafe compare :: ParseError -> ParseError -> Ordering # (<) :: ParseError -> ParseError -> Bool # (<=) :: ParseError -> ParseError -> Bool # (>) :: ParseError -> ParseError -> Bool # (>=) :: ParseError -> ParseError -> Bool # max :: ParseError -> ParseError -> ParseError # min :: ParseError -> ParseError -> ParseError # | |
Show ParseError Source # | |
Defined in Url.Unsafe showsPrec :: Int -> ParseError -> ShowS # show :: ParseError -> String # showList :: [ParseError] -> ShowS # |
Parsing
Slicing
getUsername :: Url -> Maybe Bytes Source #
Slice into the Url
and retrieve the username, if it's present
getPath :: Url -> Maybe Bytes Source #
Slice into the Url
and retrieve the path starting with '/'
, if it's present
getQuery :: Url -> Maybe Bytes Source #
Slice into the Url
and retrieve the query string starting with '?'
, if it's present
getFragment :: Url -> Maybe Bytes Source #
Slice into the Url
and retrieve the fragment starting with '#'
, if it's present
getExtension :: Url -> Maybe Bytes Source #
This function is intentionally imprecise.
E.g. getExtension "google.com/facebook.com" == Just ".com"