Skip to content
New issue

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

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

Already on GitHub? # to your account

Add support for regex wildcard group #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Megapixel99
Copy link
Collaborator

@Megapixel99 Megapixel99 commented Aug 29, 2024

Looking at Route Paths in https://expressjs.com/en/guide/routing.html, Express supports routes such as /ab?cd and /ab*cd; however, when trying to implement /ab/cd(*) (which is mentioned in this issue), you would receive the following error: Invalid regular expression: /^(?:*)$/i: Nothing to repeat. This PR should fix that error.

wesleytodd
wesleytodd previously approved these changes Aug 29, 2024
Copy link
Owner

@wesleytodd wesleytodd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, great addition! We are going to have some fun in here when we merge the upcoming express v5 changes, but this is perfect for v4 support.

EDIT: here is the WIP I was doing to integrate changes which drop a bunch of regexp related things in path-to-regexp. We are going to need to accommodate for these here, but I wanted to finish them in express first.

const params = routeLayer.keys.map((k) => {
const params = routeLayer.keys.map((k, i) => {
const prev = routeLayer.keys[i - 1]
if (!Number.isNaN(k.name) && prev?.offset + prev?.name?.length - 2 === k.offset) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to read this line a few times to make sure I followed, might be good to just add a comment about it for our future selves.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am testing this line to make sure it does not have any bugs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wesleytodd I am done double checking for bugs, please re-approve and merge at your convenience.

test/_routes.js Outdated Show resolved Hide resolved
@wesleytodd
Copy link
Owner

@Megapixel99 can you give me a ping when you are comfortable with this PR and I can dig in and prepare a release?

@Megapixel99
Copy link
Collaborator Author

Megapixel99 commented Aug 31, 2024

@Megapixel99 can you give me a ping when you are comfortable with this PR and I can dig in and prepare a release?

@wesleytodd I believe this PR is good to go. If you want me to test it further (beyond the tests I wrote for it and the app I intend to use this feature in) before you merge let me know.

@wesleytodd
Copy link
Owner

Sorry I have been super busy trying to get express v5 wrapped up. I will loop back on this soon after we release though. Is that alright? or is this blocking you? Because I trust you and the tests, so I can push a release if you are blocked on this.

@Megapixel99
Copy link
Collaborator Author

Sorry I have been super busy trying to get express v5 wrapped up. I will loop back on this soon after we release though. Is that alright? or is this blocking you? Because I trust you and the tests, so I can push a release if you are blocked on this.

@wesleytodd I do not not need this to be merged right away. I can use the branch for the specific project which requires this feature for now.

If you need help with express v5 let me know. At one point you mentioned making me a commiter on the express project (#54 (comment)) and I am happy to contribute earlier than anticipated.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants