v2.0.0
Breaking
-
Convert
default
export to namedparse
export: d439b9c
Important: No functionality has changed! Simply -how- it's imported-- import regexparam from 'regexparam'; ++ import { parse } from 'regexparam';
-
Require Node 8.x minimum runtime: bc36b93
Previously required Node 6.x
Features
-
Support native ESM imports via "exports" mapping: f2604b2
Note: This is potentially breaking for users of Node 13.0 thru 13.7 – upgrade! All of Node 13.x is officially obsolete!Conditional exports were defined, which means that CommonJS usage is still supported.
-
Added new
inject
function: 9c1a166, 3958c19, 3579e63
Convenience function for injecting values into a route pattern string.
Note: This is fully tree-shakable! Your bundle won't include it if you don't use it.import { inject } from 'regexparam'; inject('/users/:id', { id: 'lukeed' }); //=> '/users/lukeed' inject('/movies/:title.mp4', { title: 'narnia' }); //=> '/movies/narnia.mp4' inject('/:foo/:bar?/:baz?', { foo: 'aaa' }); //=> '/aaa' inject('/:foo/:bar?/:baz?', { foo: 'aaa', baz: 'ccc' }); //=> '/aaa/ccc' inject('/posts/:slug/*', { slug: 'hello', }); //=> '/posts/hello' inject('/posts/:slug/*', { slug: 'hello', wild: 'x/y/z', }); //=> '/posts/hello/x/y/z' // Missing non-optional value // ~> keeps the pattern in output inject('/hello/:world', { abc: 123 }); //=> '/hello/:world'