Skip to content

Commit b90823f

Browse files
committed
fix: remove extra non-capturing group
1 parent 5617e75 commit b90823f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "regexparam",
33
"version": "1.1.0",
44
"repository": "lukeed/regexparam",
5-
"description": "A tiny (285B) utility that converts route patterns into RegExp. Limited alternative to `path-to-regexp` 🙇‍",
5+
"description": "A tiny (276B) utility that converts route patterns into RegExp. Limited alternative to `path-to-regexp` 🙇‍",
66
"module": "dist/regexparam.mjs",
77
"main": "dist/regexparam.js",
88
"license": "MIT",

readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# regexparam [![Build Status](https://travis-ci.org/lukeed/regexparam.svg?branch=master)](https://travis-ci.org/lukeed/regexparam)
22

3-
> A tiny (285B) utility that converts route patterns into RegExp. Limited alternative to [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp) 🙇
3+
> A tiny (276B) utility that converts route patterns into RegExp. Limited alternative to [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp) 🙇
44
55
With `regexparam`, you may turn a pathing string (eg, `/users/:id`) into a regular expression.
66

@@ -45,7 +45,7 @@ function exec(path, result) {
4545
// Parameter, with Optional Parameter
4646
// ---
4747
let foo = regexparam('/books/:genre/:title?')
48-
// foo.pattern => /^\/books\/([^\/]+?)(?:\/([^\/]+?))?(?:\/)?\/?$/i
48+
// foo.pattern => /^\/books\/([^\/]+?)(?:\/([^\/]+?))?\/?$/i
4949
// foo.keys => ['genre', 'title']
5050

5151
foo.pattern.test('/books/horror'); //=> true
@@ -61,7 +61,7 @@ exec('/books/horror/goosebumps', foo);
6161
// Parameter, with suffix
6262
// ---
6363
let bar = regexparam('/movies/:title.(mp4|mov)');
64-
// bar.pattern => /^\/movies\/([^\/]+?)\.(mp4|mov)(?:\/)?\/?$/i
64+
// bar.pattern => /^\/movies\/([^\/]+?)\.(mp4|mov)\/?$/i
6565
// bar.keys => ['title']
6666

6767
bar.pattern.test('/movies/narnia'); //=> false
@@ -75,7 +75,7 @@ exec('/movies/narnia.mp4', bar);
7575
// Wildcard
7676
// ---
7777
let baz = regexparam('users/*');
78-
// baz.pattern => /^\/users\/(.*)(?:\/)?\/?$/i
78+
// baz.pattern => /^\/users\/(.*)\/?$/i
7979
// baz.keys => ['wild']
8080

8181
baz.pattern.test('/users'); //=> false

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ export default function (str) {
2020

2121
return {
2222
keys: keys,
23-
pattern: new RegExp('^' + pattern + (keys.length ? '(?:/)?' : '') + '\/?$', 'i')
23+
pattern: new RegExp('^' + pattern + '\/?$', 'i')
2424
};
2525
}

0 commit comments

Comments
 (0)