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

Discussion: Match the most specific URL, not the first found #15

Closed
christopherthielen opened this issue Dec 16, 2016 · 1 comment
Closed
Milestone

Comments

@christopherthielen
Copy link
Member

Currently if you register states with urls like:

.state('foo', {
  url: '/foo/:fooid',
  params: { bar: null, squash: true }
})
.state('foo.bar', {
  url: '/staticstring'
})
.state('foo2', {
  url: '/foo/otherstring'
})

With URL /foo/staticstring, foo is matched because it matches the pattern and its url rule was registered first. Currently, the first matched URL always wins.

Likewise, with URL /foo/otherstring, foo is matched for the same reasons.

Choose most specific match

Consider implementing heuristics where the most specific match is chosen.

  • For url: /foo/staticstringwe should detect that foo.bar is more specific than foo.
    • Deepest state wins
  • For url: /foo/otherstring we should detect that foo2 is more specific than foo.
    • Fewer parameters win?

This would have the additional benefit during lazy loading. When states are lazy loaded, there might not be a guarantee of the load order, so less specific urls could be registered before more specific ones.

@christopherthielen
Copy link
Member Author

Closed by eb2f5d7

christopherthielen added a commit that referenced this issue Jan 7, 2017
…tion in response to a URL sync

This fixes a problem that occurred when the url sync caused a redirection:

- URL changes (to `/foo`)
- Router synchronizes
- Router redirects elsewhere (to `/bar`)
- Url is updated

Now the browser history has two history entries:

- `/foo`
- `/bar`

---

Now, when the URL is updated, it uses `{ location: replace }` so the browser history only has one entry:

- `/bar`

Closes angular-ui/ui-router#3187
Closes #15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant