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

Problem with regular expression in matches() constraint #181

Open
DhyanB opened this issue Aug 14, 2014 · 2 comments
Open

Problem with regular expression in matches() constraint #181

DhyanB opened this issue Aug 14, 2014 · 2 comments

Comments

@DhyanB
Copy link

DhyanB commented Aug 14, 2014

Update: See second post for solution.

I'm using Rewrite 2.0.12. Tomcat gives me a 404 error for the following rule:

.addRule(Join.path("/page/{x}/{y}/").to("/foo/page.html")).where("x").matches(pattern).where("y").matches(pattern)

However, this one works fine:

.addRule(Join.path("/page/{x}/").to("/foo/page.html")).where("x").matches(pattern)

Lincoln asked me to test with no matches() constraints and we found out that

.addRule(Join.path("/page/{x}/{y}/").to("/foo/page.html")).where("x").where("y")

works, too. Basically, it seems to work as long as there is only one matches() constraint present. Hence these ones also work:

.addRule(Join.path("/page/{x}/{y}/").to("/foo/page.html")).where("x").matches(pattern).where("y")
.addRule(Join.path("/page/{x}/{y}/{z}").to("/foo/page.html")).where("x").matches(pattern).where("y").where("z")

Chaining multiple where(x).matches(pattern) constraints used to work in Rewrite 1.1.0.

@DhyanB
Copy link
Author

DhyanB commented Aug 15, 2014

That one cost me countless hours, but I finally figured it out. Sadly, my first post is entirely wrong, but at that time I didn't know better. I have a rule with three parameters /{sort}/{page}/{tags}, each has to match a certain pattern. The sort parameter had to match (a|b|c) (three ways of sorting items in my app). In Rewrite 1.1.0, the forward worked fine, but tags ended up having the value of page while sort and page both had the sorting value (e.g. a). The original tag value was missing. So I updated to Rewrite 2.0.12 and the same rule didn't even forward anymore, but instead gave me a 404 error. Playing around with the order of the where clauses and the number of matches constraints, I found working combinations that lead me to the assumption that no more than one matches clause was possible in the current Rewrite release. As it turned out, my regular expression was causing the error.

tl;dr

A regular expression like (a|b|c) does not work. Use a|b|c instead. That might still be a bug, but it's far less serious. Sorry for my incorrect first post.

@DhyanB DhyanB changed the title .addRule(Join.path().to()).where().matches().where().matches() does not work Problem with regular expression in matches() constraint Aug 15, 2014
@lincolnthree
Copy link
Member

Hey @DhyanB - Thanks for the update. I'm wondering why this would be the case, I'll need to play around with groups and see if I can reproduce something like this. I'm going to leave this open issue until I do.

Also, I'm sorry for not being able to try your example sooner. It's been a crazy few weeks.

Glad you figured it out!

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