Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve prefix behavior with non-segment params #71

Merged
merged 1 commit into from
Mar 2, 2016

Conversation

blakeembrey
Copy link
Member

Closes #70

@blakeembrey blakeembrey force-pushed the path-segment-suffix-patch branch from f73ccd1 to 3902509 Compare March 2, 2016 03:27
@blakeembrey blakeembrey force-pushed the path-segment-suffix-patch branch from 3902509 to 876222c Compare March 2, 2016 03:29
@blakeembrey blakeembrey merged commit 876222c into master Mar 2, 2016
@blakeembrey blakeembrey deleted the path-segment-suffix-patch branch March 2, 2016 20:46
paulmelnikow added a commit to paulmelnikow/path-to-regexp that referenced this pull request Dec 5, 2018
Thanks so much for this library! It’s come in very handy in Shields. We’ve significantly reduced the duplication in our route definitions, and we’re getting really close letting developers build badge URLs in the frontend.

We’re running into an issue when an optional token precedes the extension. Many of the routes look something like this:

`/travis/:user/:repo/:branch?.ext(svg|png)`

- That pattern matches `/travis/foo/bar/master.svg` as we’d expect
- Unexpectedly it _does not_ match `/travis/foo/bar.svg`
- Unexpectedly it _does_ match `/travis/foo/bar/.svg`

I traced the behavior back to pillarjs#71 where it was introduced. I _think_ it was unintentional since that PR was about making the leading delimiter optional for an optional token. I don’t see why the delimiter should be present before an optional in the middle.

It’s kind of an odd fix, though it makes some sense given pillarjs#71 was about fixing leading optionals.
paulmelnikow added a commit to paulmelnikow/path-to-regexp that referenced this pull request Dec 5, 2018
Thanks so much for this library! It’s come in very handy in Shields. We’ve significantly reduced the duplication in our route definitions, and we’re getting really close letting developers build badge URLs in the frontend.

We’re running into an issue when an optional token precedes the extension. Many of the routes look something like this:

`/travis/:user/:repo/:branch?.ext(svg|png)`

- That pattern matches `/travis/foo/bar/master.svg` as we’d expect
- Unexpectedly it _does not_ match `/travis/foo/bar.svg`
- Unexpectedly it _does_ match `/travis/foo/bar/.svg`

I traced the behavior back to pillarjs#71 where it was introduced. I _think_ it was unintentional since that PR was about making the leading delimiter optional for an optional token. I don’t see why the delimiter should be present before an optional in the middle.

It’s kind of an odd fix, though it makes some sense given pillarjs#71 was about fixing leading optionals.

@RedSparr0w was asking about paths like `/:optional?/:required.json` so
I added another test example to the test for that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant