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

useParam() doesn't return a parameter if the value of it starts with a hash while using the HashRouter #460

Open
MTRNord opened this issue Jul 19, 2024 · 0 comments
Labels
pr welcome Gladly accept a PR for this issue

Comments

@MTRNord
Copy link

MTRNord commented Jul 19, 2024

Describe the bug

I have this route setup currentlly:

<HashRouter>
        <Route path="/:roomId?" component={App} matchFilters={{
            roomId: /^(!|\$|#)/ // Match $ or # for the roomId
        }} />
        <Route path="/login" component={Login} />
</HashRouter>

Using http://localhost:5173/#/$test works, using http://localhost:5173/#/!test works but using http://localhost:5173/#/#test causes the roomId param to be undefined when using it.

Example usage is:

export default function App() {
    const params = useParams();

    return (
        <ErrorBoundary fallback={(err) => <div>Error: {err.message}</div>}>
            <div class="wrapper">
                <Show when={params.roomId} fallback={<p>No Room</p>} keyed>
                    <p>room</p>
                </Show>

            </div>
        </ErrorBoundary>
    )
}

Your Example Website or App

See the above for a minimal example of the issue.

Steps to Reproduce the Bug or Issue

See above for a minimal example of the issue and how to reproduce it please.

Expected behavior

I would expect that #test is equally valid as any other string and isnt omitted.

Screenshots or Videos

No response

Platform

  • OS: Linux Fedora 40
  • Browser: Firefox 128.0 (64-Bit)
  • Version: SolidJs ^1.8.18 | Solidjs-Router ^0.14.1

Additional context

I haven't checked the other routers as my app isnt SSR compatible

@MTRNord MTRNord changed the title Use param doesnt return a param if the value of it starts with a hash while using the HashRouter useParam() doesn't return a parameter if the value of it starts with a hash while using the HashRouter Jul 19, 2024
@ryansolid ryansolid added the pr welcome Gladly accept a PR for this issue label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr welcome Gladly accept a PR for this issue
Projects
None yet
Development

No branches or pull requests

2 participants