I want to have pretty url's for user profiles i.e. url.com/username
But also have reserved url's, such as url.com/categories, url.com/login etc.
I have states setup for the reserved url's e.g.
.state('categories',{
url:'/categories', // i.e. url.com/categories
...
});
Then I've tried to provide a regex for the root state that would match for usernames and not match for the above reserved url states e.g.
$stateProvider
.state('profile',{
url:'/{username:^((categories|login(?!$)).+|(?!categories|login).+)$}',
...
});
I reviewed the UI-Router URL-Routing documentation (https://github.com/angular-ui/ui-router/wiki/URL-Routing) and attempted to understand urlMatcher, as well as make my regex comply.
Currently it will take me to the reserved states e.g. url.com/categories but if I attempt to visit url.com/someusername it doesn't load the profile and takes me to url.com/
Do I need to change my regex?
Is it possible to do this with a certain regex, or is urlMatcher not capable of handling reserved + dynamic url's / 'does not match' regex?