Skip to content

PathPattern "/{foo}.*" should be more specific than "/{foo}" [SPR-15597] #20156

New issue

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

By clicking “No 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? No Sign in to your account

Closed
spring-projects-issues opened this issue May 30, 2017 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented May 30, 2017

Brian Clozel opened SPR-15597 and commented

Hi Andy Clement,

While working on further changes in the framework leveraging PathPattern, I've found the following behavior:

PathPatternParser parser = new PathPatternParser();
PathPattern p1 = parser.parse("/{foo}");
PathPattern p2 = parser.parse("/{foo}.*");
Map<String, String> r1 = p1.matchAndExtract("/file.txt");
Map<String, String> r2 = p2.matchAndExtract("/file.txt");

// works fine
assertEquals(r1.get("foo"), "file.txt");
assertEquals(r2.get("foo"), "file");

// returns -1, thus considering that "/{foo}" is more specific than "/{foo}.*"
assertThat(p1.compareTo(p2), Matchers.greaterThan(0));

Judging from our previous discussion, I'm wondering if this is now the expected behavior or if this is inconsistent with what's described in that comment.

By the way, when comparing "/{foo}" and "/{foo}.txt", "/{foo}.txt" is considered the most specific one.

Thanks,


Affects: 5.0 RC1

Referenced from: commits 77576ed

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jun 2, 2017

Andy Clement commented

I've made a minimal change to bring us in line with the AntPathMatcher behavior - PathPattern comparison now produces the expected result for Brians testcase. I've raised #20177 to look at improving things in future.

@spring-projects-issues
Copy link
Collaborator Author

Brian Clozel commented

Brilliant - Thanks Andy Clement!

No Sign up for free to join this conversation on GitHub. Already have an account? No Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants