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

Routing incorrectly matches URIs with prefixes #1483

Closed
david-perez opened this issue Jun 22, 2022 · 0 comments · Fixed by #1484
Closed

Routing incorrectly matches URIs with prefixes #1483

david-perez opened this issue Jun 22, 2022 · 0 comments · Fixed by #1484
Labels
server Rust server SDK

Comments

@david-perez
Copy link
Contributor

I discovered this while testing integration with Lambda behind API Gateway, where the deployed API contains the API stage in the URI:

Both these cases fail:

#[test]
fn foo() {
    let get_server_statistics_request_spec = RequestSpec::new(
        Method::GET,
        UriSpec::new(PathAndQuerySpec::new(
            PathSpec::from_vector_unchecked(vec![PathSegment::Literal(String::from("stats"))]),
            QuerySpec::from_vector_unchecked(vec![]),
        )),
    );

    let misses = vec![
        (Method::GET, "/beta/stats"),
        (Method::GET, "/multiple/stages/in/path/stats"),
    ];
    for (method, uri) in &misses {
        assert_eq!(
            Match::No,
            get_server_statistics_request_spec.matches(&req(method, uri, None))
        );
    }
}
@david-perez david-perez added the server Rust server SDK label Jun 22, 2022
david-perez added a commit that referenced this issue Jun 22, 2022
We are incorrectly matching URIs to the spec when the URI has a prefix
that is not in the spec.

This is because when generating the regex describing the spec, we're not
using the `^` anchor to match from the beginning of the text.

Fixes #1483.
david-perez added a commit that referenced this issue Jun 22, 2022
We are incorrectly matching URIs to the spec when the URI has a prefix
that is not in the spec.

This is because when generating the regex describing the spec, we're not
using the `^` anchor to match from the beginning of the text.

Fixes #1483.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
server Rust server SDK
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant