path_to_regexp

package
v0.0.0-...-f30d65c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2022 License: MIT, MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_DELIMITER = "/"
)

Variables

This section is empty.

Functions

func Compile

func Compile(path string) func(map[string]string) string

TODO: This needs to work

Types

type Options

type Options struct {
	// delimiter The default delimiter for segments. (default: '/')
	Delimiter string
	// whitelist List of characters to consider delimiters when parsing. (default: undefined, any character)
	Whitelist string
	// sensitive When true the regexp will be case sensitive. (default: false)
	Sensitive bool
	// strict When true the regexp allows an optional trailing delimiter to match. (default: false)
	Strict bool
	// start When true the regexp will match from the beginning of the string. (default: true)
	Start bool
	// end When true the regexp will match to the end of the string. (default: true)
	End bool
	// endsWith Optional character, or list of characters, to treat as "end" characters.
	EndsWith string
}

func NewOptions

func NewOptions() Options

type PathMatcher

type PathMatcher interface {
	MatchString(string) (bool, Result)
}

func PathToRegexp

func PathToRegexp(path string, options Options) (PathMatcher, error)

PathToRegexp converts a path to a tokenized regular expression based on `:NAME` tokens.

type Result

type Result struct {
	Results []string
	// contains filtered or unexported fields
}

type Token

type Token struct {
	Name      string
	Prefix    string
	Delimiter string
	Optional  bool
	Repeat    bool
	Pattern   string
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL