my-way
Minimal path matcher.
Usage
const route = '/users/:id'const matched = // => { id: "123" }
Segments
/literal
Literal segment/:name
Named segment/:name+
Rest segment/:name?
Optional segment/:name*
Optional rest segment/:name<regex>
Named segment with regex matching/:name+<regex>
Rest segment with regex matching/:name?<regex>
Optional segment with regex matching/:name*<regex>
Optional rest segment with regex matching
Examples
// null // { id: "123" } // { id: "123" } // { id: "123" } // null // { id: "123" } // { id: "123" } // { id: "123", status: "active" } // null // { owner: "amio", repo: "my-way", path: "package.json" } // { owner: "amio", repo: "my-way", path: "src/index.ts" } // null // { owner: "amio", repo: "my-way" } // { owner: "amio", repo: "my-way", url: "https://github.com/amio/my-way" } // { owner: "amio", repo: "my-way", url: "https://github.com/amio/my-way" }
Not supported
-
Multi slashes in pathname
// null