yaminncco / vue-sidebar-menu

A Vue.js Sidebar Menu Component

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Matching alias against URLs including query params. Version 4

tomastan opened this issue · comments

Hello,

Unfortunately I'm still stuck with Vue2 in my project, so have to play with version 4.8.1 so far.

I'm having troubles with matching alias URLs which contain query string. For example:

There are group of URLs should be grouped under one menu item:
/users/users
/users/user?id=1
/users/user?id=*

Trying to use alias and regexp, but it it does not match anyway. Unless alias is set exactly to "/users/user?id=1".
exactPath looks to apply to href, but does it ignore alias ?

{
	href: "/users/users",
	title: 'Users',
	exactPath: true,
	alias: ["\/users\/user\?id=[0-9]+", "/users/user"] // Neither works
},

Do I miss something?

exactPath match only the pathname /users/user ≠ /users/users
so you either change the path or can use alias

{
  href: '/users/users',
  title: 'Users',
  alias: '/users/user?id=(\\d+)'
}

Thanks, it looks the problem was not in exactPath (which I need to keep for cases like /users/users?query=blablabla ), but with regexp format of alias. Changing it to the shown in your example resolves the issue.

I owe you a coffee!