ember-routing-utils

Utility tools for working with the Ember `RouterService`

Usage no npm install needed!

<script type="module">
  import emberRoutingUtils from 'https://cdn.skypack.dev/ember-routing-utils';
</script>

README

ember-routing-utils

CI npm version Download Total Ember Observer Score code style: prettier
Dependabot enabled dependencies Status devDependencies Status

Some utils for working with the Ember RouterService more effectively.

Installation

ember install ember-routing-utils

Usage

routing-utils Service

getParameters(routeInfo: RouteInfo): string[]

Retrieves all parameters for a RouteInfo object and its parents in correct oder, so that you can pass them to e.g. transitionTo(routeName, ...params).

getParametersWithQueryParameters(routeInfo: RouteInfo): string[]

Same as getParameters, but also includes the final { queryParams } for convenience.

getURLFromRouteInfo(routeInfo: RouteInfo): string

Builds the URL for a RouteInfo object and its parents. Includes the rootURL.

removeRootURL(url: string): string

Removes the rootURL from a URL, so that it can be used with transitionTo(), because Ember handles this inconsistently. 🤡

If the URL does not start with the rootURL or the app has no rootURL, this just returns the original url.

prefixRootURL(url: string): string

Prefixes the rootURL to a URL.

If the URL already starts with the rootURL or the app has no rootURL, this just returns the original url.