router icon indicating copy to clipboard operation
router copied to clipboard

is it possible to treat `#` as a normal character (and not a "hash" prefix) on a route

Open 4www opened this issue 3 years ago • 1 comments

Hello,

Have been using vaadin router in all my recent projects, and pretty happy with it, thanks!

Today, I fail to figure if it is possible to treat the # character (located as the first character of a route parameter), as a character, instead of the hash prefix.

In my use case, i'd like to find the id route param, from all routes after / starting with # or @ (i'm trying to map matrix/element room & user id, which have these two characters as prefix).

Links:

  • test: https://codesandbox.io/s/dreamy-fog-ej95q4?file=/index.html:525-582
  • docs: https://vaadin.github.io/router/vaadin-router/demo/#vaadin-router-route-parameters-demos
  • path detection uses the npm lib: https://github.com/pillarjs/path-to-regexp#parameters

test 1

{path: '/:id', component: 'page-profile'}

It works if id starts with @, but not with #

test 2

{path: '/profile/#:room_id', component: 'page-profile'} # is not getting triggered, even if `#` is escaped in a regex query
{path: '/profile/@:user_id', component: 'page-profile'} # is getting triggered correctly

expected result

  • in the case example.com/profile/#matrix:matrix.org where room id is #matrix:matrix.org, the route param id, would have the values #matrix:matrix.org or in the case example.com/profile/@test-user:matrix.org, where a user id is @test-user:matrix.org, the route param user_id would have the value @test-user:matrix.org

4www avatar Feb 22 '22 15:02 4www