preactjs / wmr

👩‍🚀 The tiny all-in-one development tool for modern web apps.
https://wmr.dev/
MIT License
4.92k stars 109 forks source link

Router segment wildcards don't match when no segment is provided #962

Open ollelogdahl opened 1 year ago

ollelogdahl commented 1 year ago

Describe the bug When trying to resolve a subrouter that has a / path, it fails.

To Reproduce Steps to reproduce the behavior:

function Ok() {
    return (
        <p>Ok</p>
    )
}

function Inner() {
    return (
        <Router>
            <Route path='/' component={Ok} />
            <Route path='/a' component={Ok} />
        </Router>
    )
}

function Outer() {
    return (
        <LocationProvider>
            <Router>
                <Inner path='/more/*' />
                <Inner path='/*' />
            </Router>
        </LocationProvider>
    )
}

render(<Outer />, document.body);

Expected behavior

I expect / in a subrouter to resolve if there is no extention to what the outer router matched.

Only /a and /more/a resolves at the moment.

Bug occurs with: Just using preact-iso in dev-mode.

Desktop (please complete the following information):

rschristian commented 1 year ago

Personally, I'd call this behavior correct. / and /* are two different patterns and should be handled as such.