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

Simplify use of regular expressions #3

Closed
amitguptagwl opened this Issue Jun 26, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@amitguptagwl
Member

amitguptagwl commented Jun 26, 2018

This is how the dynamic route is added currently;

router.on("GET", "/this/is/:dynamic/with/:pattern(\\d+)", handler);

We are planning to name regular expressions used for path parameters

router.addNamedExpression("num","\\d+");
router.on("GET", "/this/is/:dynamic/with/:pattern(:num:)", handler); //valid
//router.on("GET", "/this/is/:dynamic/with/:pattern(\\d+)", handler); //valid

Named expression can be added in following two ways

router.addNamedExpression("num","\\d+");
router.addNamedExpressions({
   "name1" : "regx1",
   "name2" : "regx2",
});

Named expressions will be replaced at the time of adding the route. So it should not impact application performance.

@shuklajay117

This comment has been minimized.

Show comment
Hide comment
@shuklajay117

shuklajay117 Jul 23, 2018

Contributor

I'm working on it

Contributor

shuklajay117 commented Jul 23, 2018

I'm working on it

@amitguptagwl

This comment has been minimized.

Show comment
Hide comment
@amitguptagwl

amitguptagwl Jul 23, 2018

Member

I hope you're clear with the motive behind this issue. Feel free to clear any doubt

Member

amitguptagwl commented Jul 23, 2018

I hope you're clear with the motive behind this issue. Feel free to clear any doubt

@shuklajay117

This comment has been minimized.

Show comment
Hide comment
@shuklajay117

shuklajay117 Jul 23, 2018

Contributor

My understanding is as below:

It should support of adding regular expression using addNameExpression method. We will keep track of all regex into a map. Once user have defined some re-usable regex to it, they are able to use it using :regexKeyName: in url. We need to make sure this name should get replaced with specified regex pattern before it gets registered. I assume that there can be multiple dynamic regex keys used in a url so we need to replace all of them.

Please correct me if anything wrong!

Contributor

shuklajay117 commented Jul 23, 2018

My understanding is as below:

It should support of adding regular expression using addNameExpression method. We will keep track of all regex into a map. Once user have defined some re-usable regex to it, they are able to use it using :regexKeyName: in url. We need to make sure this name should get replaced with specified regex pattern before it gets registered. I assume that there can be multiple dynamic regex keys used in a url so we need to replace all of them.

Please correct me if anything wrong!

@amitguptagwl

This comment has been minimized.

Show comment
Hide comment
@amitguptagwl

amitguptagwl Jul 23, 2018

Member

You're right.

Member

amitguptagwl commented Jul 23, 2018

You're right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment