{"id":13807706,"url":"https://github.com/thoov/ember-redirect","last_synced_at":"2025-04-23T13:43:30.769Z","repository":{"id":21896573,"uuid":"25220495","full_name":"thoov/ember-redirect","owner":"thoov","description":"EmberJS redirect addon for Ember-CLI. This addon aims to be a simple and easy way to preform route based redirects with minimal effort.","archived":false,"fork":false,"pushed_at":"2018-02-14T23:58:57.000Z","size":266,"stargazers_count":27,"open_issues_count":2,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-19T03:56:28.932Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thoov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-14T18:28:12.000Z","updated_at":"2023-04-11T13:15:55.000Z","dependencies_parsed_at":"2022-08-17T22:35:05.985Z","dependency_job_id":null,"html_url":"https://github.com/thoov/ember-redirect","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoov%2Fember-redirect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoov%2Fember-redirect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoov%2Fember-redirect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoov%2Fember-redirect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thoov","download_url":"https://codeload.github.com/thoov/ember-redirect/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250441411,"owners_count":21431168,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T01:01:29.242Z","updated_at":"2025-04-23T13:43:30.660Z","avatar_url":"https://github.com/thoov.png","language":"JavaScript","readme":"# Ember Redirect\n\nEmberJS 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.\n\n[![Build Status](https://travis-ci.org/thoov/ember-redirect.svg?branch=master)](https://travis-ci.org/thoov/ember-redirect)\n[![Ember Observer Score](http://emberobserver.com/badges/ember-redirect.svg)](http://emberobserver.com/addons/ember-redirect)\n[![npm version](https://badge.fury.io/js/ember-redirect.svg)](http://badge.fury.io/js/ember-redirect)\n## Installation ##\n\n```\nember install ember-redirect\n```\n\n## Usage ##\n\n```js\nconst Router = Ember.Router.extend({\n  location: config.locationType,\n  rootURL: config.rootURL,\n\n  redirects: {\n    'sample'        : 'something',\n    'testing.index' : 'something',\n    'testing.foo'   : 'bar',\n    'bar.cat'       : 'testing.foo',\n    'account'       : 'user',\n    'profile'       : 'user'\n  }\n});\n\nRouter.map(function() {\n  this.route('bar');\n  this.route('sample'); // will redirect to something\n  this.route('something');\n\n  this.route('testing', function() { // will redirect to something\n    this.route('foo'); // will redirect to bar\n\n    this.route('bar', function() {\n      this.route('cat'); // will redirect to testing.foo\n    });\n  });\n\n  this.route('user', { path: 'user/:user_id/something/:something' });\n  this.route('profile', { path: 'profile/:profile_id/user/:user_id' }); // will redirect to user\n  this.route('account', { path: 'account/:account_id/other/:other_id' }); // will redirect to user\n});\n```\n\n## Dynamic Routes ##\n\nDynamic routes are supported and follow two rules:\n\nThe first is that if you are redirecting from one route to another and they share a common\ndynamic segment then those are preserved. As an example we have the following routes:\n\n```js\nredirects: {\n  'profile' : 'user'\n}\n\n...\n\nthis.route('user', { path: 'user/:user_id/something/:something' });\nthis.route('profile', { path: 'profile/:profile_id/user/:user_id' });\n```\n\nOur profile url would be something like this: `/profile/1/user/13` and would redirect to\nthe user route of: `/user/13/something/1`. You can see in this example that both routes\nshare the same `:user_id` segment and those are mapped together.\n\nThe next rule is that once all shared dynamic segments are matched (or there are none) then\nwe simple fall back to doing a 1:1 match. As an example:\n\n```js\nredirects: {\n  'account' : 'user'\n}\n\n...\n\nthis.route('user', { path: 'user/:user_id/something/:something' });\nthis.route('account', { path: 'account/:account_id/other/:other_id' });\n```\n\nOur account url would be something of this form: `/account/34/other/17` and would\nredirect to the user route of: `/user/34/something/17`. As you can see there are no\nshared dynamic segments so we just perform a 1:1 mapping where the first segment in account\nmaps to the first segment in user.\n\n## External Routes ##\n\nExternal routes are supported in the `redirects` hash. You simply pass the url you want to\nredirect to as a string. The redirect string must resemble a url.\n\nAn external redirect should look like:\n\n```js\nredirects: {\n  'external' : 'https://github.com/thoov/ember-redirect'\n}\n\n...\n\nthis.route('external');\n```\n\n## Running tests ##\n\n* `git clone git@github.com:thoov/ember-redirect.git`\n* `cd ember-redirect`\n* `yarn`\n* `ember t`\n  * or `ember s` then visit [localhost tests](http://localhost:4200/tests)\n* Tests are also run on [TravisCI](https://travis-ci.org/thoov/ember-redirect)\n\n## Feedback or Issues ##\n\nIf you have any feedback, encounter any bugs, or just have a question, please feel free to create a [github issue](https://github.com/thoov/ember-redirect/issues/new) or send me a tweet at [@thoov](https://twitter.com/thoov).\n","funding_links":[],"categories":["Packages"],"sub_categories":["Routing addons"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoov%2Fember-redirect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthoov%2Fember-redirect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoov%2Fember-redirect/lists"}