Module

URI.Path.Segment

Package
purescript-uri
Repository
purescript-contrib/purescript-uri

#PathSegment Source

newtype PathSegment

A path segment. Can be empty, as this is required to represent some paths - segments are joined together with slashes, so in cases where a path contains multiple contiguous slashes this is represented by a group of empty path segments. Corresponds to segment in the spec.

Instances

#segmentFromString Source

segmentFromString :: String -> PathSegment

Constructs a segment 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 unsafeSegmentFromString instead.

#segmentToString Source

segmentToString :: PathSegment -> String

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

#unsafeSegmentFromString Source

unsafeSegmentFromString :: String -> PathSegment

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

#unsafeSegmentToString Source

unsafeSegmentToString :: PathSegment -> String

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

#parseSegment Source

parseSegment :: Parser String PathSegment

A parser for a segment component of a URI.

#printSegment Source

printSegment :: PathSegment -> String

A printer for a segment component of a URI.

#PathSegmentNZ Source

newtype PathSegmentNZ

A path segment that cannot be empty. Corresponds to segment-nz in the spec.

Instances

#segmentNZFromString Source

segmentNZFromString :: NonEmptyString -> PathSegmentNZ

Constructs a non-empty segment 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 unsafeSegmentNZFromString instead.

#segmentNZToString Source

segmentNZToString :: PathSegmentNZ -> NonEmptyString

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

#unsafeSegmentNZFromString Source

unsafeSegmentNZFromString :: NonEmptyString -> PathSegmentNZ

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

#unsafeSegmentNZToString Source

unsafeSegmentNZToString :: PathSegmentNZ -> NonEmptyString

Returns the string value for a non-empty segment without percent-decoding. Only "unsafe" in the sense that values this produces may need further decoding, the name is more for symmetry with the segmentNZFromString/ unsafeSegmentNZFromString pairing.

#parseSegmentNZ Source

parseSegmentNZ :: Parser String PathSegmentNZ

A parser for a segment-nz component of a URI.

#printSegmentNZ Source

printSegmentNZ :: PathSegmentNZ -> String

A printer for a segment-nz component of a URI.

#PathSegmentNZNC Source

newtype PathSegmentNZNC

A path segment that cannot be empty or contain the : character. Corresponds to segment-nz-nc in the spec.

Instances

#segmentNZNCFromString Source

segmentNZNCFromString :: NonEmptyString -> PathSegmentNZNC

Constructs a non-empty-no-colon segment 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 unsafeSegmentNZNCFromString instead.

#segmentNZNCToString Source

segmentNZNCToString :: PathSegmentNZNC -> NonEmptyString

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

#unsafeSegmentNZNCFromString Source

unsafeSegmentNZNCFromString :: NonEmptyString -> PathSegmentNZNC

Returns the string value for a non-empty-no-colon segment, percent-decoding any characters that require it.

#unsafeSegmentNZNCToString Source

unsafeSegmentNZNCToString :: PathSegmentNZNC -> NonEmptyString

Returns the string value for the non-empty-no-colon segment without percent-decoding. Only "unsafe" in the sense that values this produces may need further decoding, the name is more for symmetry with the segmentNZNCFromString/unsafeSegmentNZNCFromString pairing.

#parseSegmentNZNC Source

parseSegmentNZNC :: Parser String PathSegmentNZNC

A parser for a segment-nz-nc component of a URI.

#printSegmentNZNC Source

printSegmentNZNC :: PathSegmentNZNC -> String

A printer for a segment-nz-nc component of a URI.

#segmentChar Source

segmentChar :: Parser String Char

The supported path segment characters, excluding percent-encodings.

#segmentNCChar Source

segmentNCChar :: Parser String Char

The supported no-colon path segment characters, excluding percent-encodings.