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

Match paths with regexes #141

Closed
evanleonard opened this issue Sep 19, 2013 · 12 comments
Closed

Match paths with regexes #141

evanleonard opened this issue Sep 19, 2013 · 12 comments
Milestone

Comments

@evanleonard
Copy link
Contributor

Hi again, I'm trying to use the "path" parameter, but running into an issue where my paths look like "/users/5647".

is it possible today to have a path like "/users/*" that will match the above current_path?

What I'm getting right now is an infinite redirect loop =(

@sorich87
Copy link
Owner

It's not possible but we'll consider it. Pull request welcome.

P.S.: I changed the issue title from How to use "path" with ids in it?.

@evanleonard
Copy link
Contributor Author

Right, better title. It looks like you can somehow override isRedirect with a custom function today, is that true?

@ghost ghost assigned sorich87 Sep 19, 2013
@sorich87
Copy link
Owner

Yes, you can do that.

@LostCrew
Copy link
Contributor

@evanleonard right after you create an instance of your tour, you can simply redefine _isRedirect with your custom function:

var tour = new Tour();

// override default method
tour._isRedirect = function() {
    // custom _isRedirect logic
};

hope it helps.

@LostCrew
Copy link
Contributor

@evanleonard are you gonna submit a pull request for the original purpose of the issue? can i instead close this issue?

@evanleonard
Copy link
Contributor Author

Go ahead and close this. I was able to do what I need by overriding _redirect for now.

@sorich87
Copy link
Owner

Why not submit a pull request? Matching with regexes is a very useful feature. ;)

@emmenko
Copy link
Contributor

emmenko commented Sep 29, 2013

I would also like to see a pull request :)

@LostCrew
Copy link
Contributor

👍 i obviously prefer to receive a shiny pull-request as well!

@evanleonard
Copy link
Contributor Author

As would I, of course. But time is limited, and i was able to solve my issue another way for now.

FWIW, here is my workaround:

this.tour._isRedirect = function(path, currentPath) {
var isRedirect = false;
if(path != null && path !== "") {
path = path.replace(/?.*$/, "").replace(//?$/, "");
currentPath = currentPath.replace(//?$/, "");
isRedirect = currentPath.indexOf(path) != 0;
}
return isRedirect;
}

Basically is accepts any path that starts with the value of the path option on the step. Then I also needed to get the tour to sync to the right step when the user goes to the new page, so added the following method in the flow:

_syncStep: function() {
var path = document.location.pathname;
if(this.tour._current==1 && path.indexOf("/roles/") == 0) {
this.tour.goto(2);
}
else if(this.tour._current==3 && path.indexOf("/roles/") == 0) {
this.tour.goto(4);
}
else if(this.tour._current==7 && path.indexOf("/roles/") == 0) {
this.tour.goto(6);
}
},

On Sep 29, 2013, at 1:04 PM, Emanuele notifications@github.com wrote:

i obviously prefer to receive a shiny pull-request as well!


Reply to this email directly or view it on GitHub.

@sorich87
Copy link
Owner

sorich87 commented Feb 2, 2014

Fixed in 1a82a2b. You cannot set the path option to a value like ^/users/\d+$.

@sorich87 sorich87 closed this as completed Feb 2, 2014
@luttor
Copy link

luttor commented Jun 21, 2016

after redirect dont function the tour...

help me please!

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

No branches or pull requests

5 participants