solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.14k stars 147 forks source link

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

Open MTRNord opened 3 months ago

MTRNord commented 3 months ago

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

Additional context

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