EmberJS Redirect addon for Ember-CLI. This addon aims to be a simple and easy way to preform route based redirects with minimal effort. The goal is to support legacy links and link-tos which can "redirect" to a new route. You will be still be able to extend off of these "old" routes which should allow building new features much easier then having to start from scratch in a large project. Also looking at your router.js file should easily show you where certain routes will redirect to instead of hiding that inside of mixins as an example.
ember install ember-redirect
const Router = EmberRouter;Router;
Dynamic routes are supported and follow two rules:
The first is that if you are redirecting from one route to another and they share a common dynamic segment then those are preserved. As an example we have the following routes:
redirects:'profile' : 'user'...this;this;
Our profile url would be something like this:
/profile/1/user/13 and would redirect to
the user route of:
/user/13/something/1. You can see in this example that both routes
share the same
:user_id segment and those are mapped together.
The next rule is that once all shared dynamic segments are matched (or there are none) then we simple fall back to doing a 1:1 match. As an example:
redirects:'account' : 'user'...this;this;
Our account url would be something of this form:
/account/34/other/17 and would
redirect to the user route of:
/user/34/something/17. As you can see there are no
shared dynamic segments so we just perform a 1:1 mapping where the first segment in account
maps to the first segment in user.
External routes are supported in the
redirects hash. You simply pass the url you want to
redirect to as a string. The redirect string must resemble a url.
An external redirect should look like:
redirects:'external' : ''...this;
git clone firstname.lastname@example.org:thoov/ember-redirect.git
ember sthen visit localhost tests
- Tests are also run on TravisCI