| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Text
Description
Shared text parsing, rendering and storage without dependencies on other core modules. Inbound routes and outbound artifact filenames share the same path-component gate.
Synopsis
- nonBlank :: Text -> Maybe Text
- stripTrailingSlash :: Text -> Text
- joinUrlPath :: Text -> Text -> Text
- urlFilename :: Text -> Maybe Text
- urlFilenameComponent :: Text -> Text
- isSafeComponent :: Text -> Bool
- afterFirst :: Text -> Text -> Text
- data LowerPrefix
- httpsPrefix :: LowerPrefix
- httpPrefix :: LowerPrefix
- lowerPrefixChars :: LowerPrefix -> Int
- isPrefixOfLowered :: LowerPrefix -> Text -> Bool
- registryPath :: Text -> Text
- readDecimalText :: Integral a => Text -> Maybe a
- readHexText :: Integral a => Text -> Maybe a
- renderIso8601Utc :: UTCTime -> Text
- displayExceptionT :: Exception e => e -> Text
- textStorageBytes :: Text -> Int
Documentation
nonBlank :: Text -> Maybe Text Source #
The text trimmed of surrounding whitespace, or Nothing when nothing remains.
An empty or all-whitespace value therefore counts as absent.
stripTrailingSlash :: Text -> Text Source #
Drop every trailing slash from a URL base, so https://host// and https://host agree.
joinUrlPath :: Text -> Text -> Text Source #
Join a URL base and an already-encoded path with exactly one slash, whatever trailing slashes the base writes. It appends the path verbatim, and neither encodes nor validates it.
urlFilename :: Text -> Maybe Text Source #
The final URL path component, preserving its encoded spelling without query or fragment.
Both the raw and once-decoded component must pass isSafeComponent, with valid decoded UTF-8.
urlFilenameComponent :: Text -> Text Source #
The raw final URL path component without query or fragment, possibly empty. No decoding or validation occurs. Callers must validate and encode it before URL construction.
isSafeComponent :: Text -> Bool Source #
Refuse empty components, traversal, separators, and controls. Callers must still percent-encode on URL construction.
afterFirst :: Text -> Text -> Text Source #
The text after needle's first occurrence, or all of hay if absent. The scheme separator
matches first, so a crafted "https://169.254.169.254/x?u=https://ok" gates on the host dialled.
data LowerPrefix Source #
A lower-case prefix with its length in characters, so checking for it never measures a text. The constructor stays private, so each count sits beside its prefix in this module.
Instances
| Show LowerPrefix Source # | |
Defined in Ecluse.Core.Text Methods showsPrec :: Int -> LowerPrefix -> ShowS # show :: LowerPrefix -> String # showList :: [LowerPrefix] -> ShowS # | |
httpsPrefix :: LowerPrefix Source #
The https:// scheme prefix.
httpPrefix :: LowerPrefix Source #
The http:// scheme prefix.
lowerPrefixChars :: LowerPrefix -> Int Source #
The prefix's length in characters.
isPrefixOfLowered :: LowerPrefix -> Text -> Bool Source #
Whether the prefix begins the lower-cased text. It lowers only the prefix's length of the text,
which suffices because toLower maps each character on its own to at least one.
registryPath :: Text -> Text Source #
The path half of an absolute URL, from the first slash after the authority. It splits on the first scheme separator, so a later one inside the URL cannot move where the path starts.
readHexText :: Integral a => Text -> Maybe a Source #
The non-negative integer a bare hexadecimal digit run spells. The 0x prefix that
Data.Text.Read.hexadecimal takes is refused, so a caller strips and judges the prefix itself.
renderIso8601Utc :: UTCTime -> Text Source #
Match iso8601Show, using a builder for years 0-9999 below 86 400 seconds.
Other instants delegate to iso8601Show to preserve its representation.
displayExceptionT :: Exception e => e -> Text Source #
Render an exception as Text for a log line or error value.
textStorageBytes :: Text -> Int Source #
The byte size of the array behind a text. A slice keeps the whole array of the text it came from.