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

[BUG] Regex route with alias, with using generate #125

Closed
petrck opened this issue May 8, 2017 · 3 comments
Closed

[BUG] Regex route with alias, with using generate #125

petrck opened this issue May 8, 2017 · 3 comments

Comments

@petrck
Copy link

petrck commented May 8, 2017

Hi, I found bug, when I create regex route with alias (I does mean "as"), after this, I call generate method, for this route, and I got this:

result.replace is not a function

problem is here:

if (route.name === name) {
     result = route.route;
         for (key in data) {
                 result = result.replace(':' + key, data[key]);
         }
    }
return result;

when route.route is regular expression, cannot have function replace, as string have.

Is possible fix it please? Thank you. #

@petrck petrck changed the title Regex route with alias, bug with using generate [BUG] Regex route with alias, bug with using generate May 8, 2017
@petrck petrck changed the title [BUG] Regex route with alias, bug with using generate [BUG] Regex route with alias, with using generate May 8, 2017
@krasimir
Copy link
Owner

Good catch. I'll take a look soon.

@krasimir
Copy link
Owner

I just released 4.7.3 which fixes the failing. However, the generated string is probably not what you want. And that's because there's no a simple way to fulfill the regex. When the route is a string is easy because it is a simple find and replace. While with the regex we need an analyze to understand where the capture groups are. I feel that this is out of the scope of this library.

@krasimir
Copy link
Owner

krasimir commented Dec 21, 2020

Just a note that in version 8.0.0 the named routes and routes as regexp are depricated. Version 8.0.0 will be published soon.

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

No branches or pull requests

2 participants