gitwtfhub

wtf is path-to-regexp?

yyx990803/path-to-regexp — explained in plain English

Analysis updated 2026-07-17 · repo last pushed 2016-07-15

2TypeScriptAudience · developerComplexity · 2/5DormantSetup · easy

TL;DR

A TypeScript library that turns route patterns like /user/:id into regular expressions for URL matching, and can also build URLs back from parameter values.

Mindmap

mindmap
  root((repo))
    What it does
      Route pattern to regex
      Extracts URL parameters
      Builds URLs from values
      Handles edge cases
    Tech stack
      TypeScript
      Regular expressions
    Use cases
      Power web routers
      Match dynamic URLs
      Generate links
      Validate custom patterns
    Audience
      Web framework developers
      TypeScript developers
      Routing library authors

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Turn an Express-style route like /posts/:id into a regex that matches real URLs.

REASON 2

Extract parameter values, such as userId and postId, from an incoming URL path.

REASON 3

Generate a concrete URL string from a route pattern and a set of parameter values.

REASON 4

Build a custom routing system with optional, repeating, or regex-constrained parameters.

What's in the stack?

TypeScript

How it stacks up

yyx990803/path-to-regexpanuj-kumary/your-github-contributionsarashthr/hugo-flow
Stars222
LanguageTypeScriptTypeScriptTypeScript
Last pushed2016-07-152026-06-07
MaintenanceDormantMaintained
Setup difficultyeasymoderatemoderate
Complexity2/52/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 5min

npm install and import, no external services required.

Yoink these prompts

Prompt 1
Show me how to use this library to match /api/users/:userId/posts/:postId and extract userId and postId.
Prompt 2
How do I make a route parameter optional or repeating with this library, like :tags+?
Prompt 3
Generate a URL string from this library given a route pattern and a params object.
Prompt 4
Explain how to restrict a route parameter to digits only using this library's custom regex syntax.
Prompt 5
Help me integrate this library into my own routing system with TypeScript types.

Frequently asked questions

wtf is path-to-regexp?

A TypeScript library that turns route patterns like /user/:id into regular expressions for URL matching, and can also build URLs back from parameter values.

What language is path-to-regexp written in?

Mainly TypeScript. The stack also includes TypeScript.

Is path-to-regexp actively maintained?

Dormant — no commits in 2+ years (last push 2016-07-15).

How hard is path-to-regexp to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is path-to-regexp for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.