Module

URI.Query

Package
purescript-uri
Repository
slamdata/purescript-uri

#Query Source

newtype Query

The query component of a URI.

This type treats the entire string as an undifferentiated blob, if you would like to deal with the common ?key1=value1&key2=value2 format, take a look at URI.Extra.QueryPairs.

Instances

#fromString Source

fromString :: String -> Query

Constructs a query value from a string, percent-encoding any characters that require it. Note that running this on a string that has already had percent-encoding applied will double-encode it, for those situations use unsafeFromString instead.

fromString "foo" = unsafeFromString "foo"
fromString "foo#bar" = unsafeFromString "foo%23bar"
fromString "foo%23bar" = unsafeFromString "foo%2523bar"

#toString Source

toString :: Query -> String

Returns the string value for a query, percent-decoding any characters that require it.

toString (unsafeFromString "foo") = "foo"
toString (unsafeFromString "foo%23bar") = "foo#bar"

#unsafeFromString Source

unsafeFromString :: String -> Query

Constructs a query value from a string directly - no percent-encoding will be applied. This is useful when using a custom encoding scheme for the query, to prevent double-encoding.

#unsafeToString Source

unsafeToString :: Query -> String

Returns the string value for a query without percent-decoding. Only "unsafe" in the sense that values this produces may need further decoding, the name is more for symmetry with the fromString/unsafeFromString pairing.

#parser Source

parser :: Parser String Query

A parser for the query component of a URI. Expects values with a '?' prefix.

#print Source

print :: Query -> String

A printer for the query component of a URI. Will print the value with a '?' prefix.

#queryChar Source

queryChar :: Parser String Char

The supported query characters, excluding percent-encodings.