Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- addPathNormalizer :: ScottyM ()
- pathNormalizerAction :: ActionM ()
- data NormalizationResult a
- = Invalid
- | AlreadyNormal
- | Normalized a
- normalizePath :: Text -> NormalizationResult Text
- normalizeSegmentList :: [Text] -> NormalizationResult [Text]
Scotty action
addPathNormalizer :: ScottyM () Source #
Adds a Scotty route that matches all non-normalized paths, where the action redirects to the corresponding normalized path.
pathNormalizerAction :: ActionM () Source #
A Scotty action which issues a redirect to the normalized
form of the request target, or aborts (with next
) if the
request target is already a normal path.
Normalization implementation
data NormalizationResult a Source #
Instances
Functor NormalizationResult Source # | |
Defined in Web.Scotty.PathNormalizer fmap :: (a -> b) -> NormalizationResult a -> NormalizationResult b # (<$) :: a -> NormalizationResult b -> NormalizationResult a # | |
Show a => Show (NormalizationResult a) Source # | |
Defined in Web.Scotty.PathNormalizer showsPrec :: Int -> NormalizationResult a -> ShowS # show :: NormalizationResult a -> String # showList :: [NormalizationResult a] -> ShowS # |
normalizePath :: Text -> NormalizationResult Text Source #
A path that's already in normal form:
>>>
normalizePath "/one/two/three"
AlreadyNormal
A path that contains empty segments:
>>>
normalizePath "//one/./two/three/"
Normalized "/one/two/three"
A path that goes "up" a directory:
>>>
normalizePath "/one/two/three/../four"
Normalized "/one/two/four"
A path that goes up too far:
>>>
normalizePath "/one/../../two/three"
Invalid
The root path is a normalized path:
>>>
normalizePath "/"
AlreadyNormal
The empty string is not a valid path (because a path must begin with a slash):
>>>
normalizePath ""
Invalid
normalizeSegmentList :: [Text] -> NormalizationResult [Text] Source #
A path that's already in normal form:
>>>
normalizeSegmentList ["one", "two", "three"]
AlreadyNormal
A path that contains empty segments:
>>>
normalizeSegmentList ["", "one", ".", "two", "three"]
Normalized ["one","two","three"]
A path that goes "up" a directory:
>>>
normalizeSegmentList ["one", "two", "three", "..", "four"]
Normalized ["one","two","four"]
A path that goes up too far:
>>>
normalizeSegmentList ["one", "..", "..", "two", "three"]
Invalid
The empty string is a normalized path:
>>>
normalizeSegmentList []
AlreadyNormal