Skip to content

Day 2 afternoon: prefix_matches - solution bug #471

Answered by mgeisler
Traf333 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Traf333,

Thanks for the kind words!

I've just found that solution example might not work correctly with some edge cases like

assert!(prefix_matches(
        "/v1/publishers/*/books",
        "/v1/publishers/foo/bar/baz/books"
    ));

so, probably match pattern should consider that wildcard might be more than one step, what do you think?

Actually, this is not supposed to match — the idea of the wildcard is that it only matches a single "segment" and a "segment" is the text between two / characters.

In your code, I suppose a[i + 1] could result in a panic if the i is equal to a.len()-1? Or is there some reason why we cannot reach that index?

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mgeisler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants