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

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

Open
ollelogdahl opened this issue Jul 12, 2023 · 1 comment
Open
Labels
bug Something isn't working

Comments

@ollelogdahl
Copy link

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.

  • / Should resolve
  • /a Should resolve
  • /more Should resolve
  • /more/a Should resolve

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):

  • OS: Linux
  • Browser: Firefox
  • Node Version: 18.19.1
  • WMR Version: preact-iso@2.3.1
@ollelogdahl ollelogdahl added the bug Something isn't working label Jul 12, 2023
@rschristian
Copy link
Member

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

@rschristian rschristian changed the title Subroutes with / doesn't work Router segment wildcards don't match when no segment is provided Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants