Documentation
¶
Overview ¶
Package rulematch provides pattern compilation and capture substitution shared by redirect and rewrite rules. Callers choose the pattern syntax and own destination normalization.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureTokens ¶
CaptureTokens matches input and returns a replacer for its numbered capture groups ($1, $2, ...), or nil when the pattern does not match. A match without capture groups returns a non-nil replacer that leaves the target unchanged. Captures are preserved verbatim unless unescaped is set. In that case, path segments are escaped before substitution because rewrite decodes the resulting path again. This prevents a literal "%2e%2e" capture from becoming "..". Empty values and trailing slashes are preserved in either mode.
Adapted from https://github.com/labstack/echo/blob/master/middleware/rewrite.go.
func DotSegments ¶ added in v3.7.0
DotSegments counts the "." and ".." segments of s as some reader may: "%2e" is a dot, "\", "%2f" and "%5c" are slashes, and "?" and "#" end a segment, not the count, so a capture cannot hide one.
func MustCompilePath ¶ added in v3.7.0
MustCompilePath compiles a rewrite pattern: path text matched as written, each "*" a "(.*)" capture.
func MustCompileRegexp ¶ added in v3.7.0
MustCompileRegexp compiles a redirect pattern: regexp syntax with its groups and flags, each "*" a "(.*)" capture. An invalid pattern panics.
Types ¶
This section is empty.