Skip to content

PathPattern: inconsistent behavior for * and ** #35727

@mcollovati

Description

@mcollovati

It looks like that PathPattern works inconsistently whit with * and ** rules in matching a string without trailing '/

For example:
/resources/* matches /resources/path but not /resources
/resources/** matches both /resources/path AND /resources

The same holds also for {path} and {*path}, but at least the behavior is documented for {*path}.

I wonder if this ambiguity is by design or if it can be considered a bug.
If this is the expected behavior, it would be good to document it also for **.

Can be reproduced with the following test

    @Test
    void myTest() {
        HttpServletRequest request = new MockHttpServletRequest("GET", "/resources");
        assertFalse(PathPatternRequestMatcher.pathPattern("/resources/*").matches(request));
        assertFalse(PathPatternRequestMatcher.pathPattern("/resources/{path}").matches(request));

         // The following assertions fail    
        assertFalse(PathPatternRequestMatcher.pathPattern("/resources/**").matches(request));
        assertFalse(PathPatternRequestMatcher.pathPattern("/resources/{*path}").matches(request));
    }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions