The path argument is used to define parameters and populate keys. The RegExp returned by path-to-regexp is intended for ordered data (e.g. pathnames, hostnames). It can not handle arbitrarily ordered data (e.g. query strings, URL fragments, JSON, etc). When using paths that contain query strings, you need to escape the question mark (?) to ensure it does not flag the parameter as optional. Backslashes need to be escaped with another backslash in JavaScript strings. It is possible to write an unnamed parameter that only consists of a regexp. It works the same the named parameter, except it will be numerically indexed. When dealing with query strings, escape the question mark (?) so it doesn't mark the parameter as optional. Handling unordered data is outside the scope of this library. Parameters can be suffixed with an asterisk (*) to denote a zero or more parameter matches.

Features

  • Path-To-RegExp exposes the two functions used internally that accept an array of tokens
  • Transform an array of tokens into a matching regular expression
  • Transform an array of tokens into a path generator function
  • RegExp special characters can only be used in a parameter
  • Parameters have suffixes that augment meaning
  • Compatibility with Express <= 4.x

Project Samples

Project Activity

See All Activity >

Categories

Text Editors

License

MIT License

Follow Path-to-RegExp

Path-to-RegExp Web Site

Other Useful Business Software
$300 Free Credits for Your Google Cloud Projects Icon
$300 Free Credits for Your Google Cloud Projects

Start building on Google Cloud with $300 in free credits. No commitment, no credit card required until you're ready to scale.

Launch your next project with $300 in free Google Cloud credits—no strings attached. Test, build, and deploy without risk. Use your credits across the entire Google Cloud platform to find what works best for your needs. After your credits are used, continue with always-free tier services. Only pay when you're ready to scale. Sign up in minutes and start exploring.
Start Free Trial
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of Path-to-RegExp!

Additional Project Details

Programming Language

TypeScript

Related Categories

TypeScript Text Editors

Registered

2021-08-31