github.com/outbrain/consul@v1.4.5/ui-v2/app/helpers/href-to.js (about) 1 // This helper requires `ember-href-to` for the moment at least 2 // It's similar code but allows us to check on the type of route 3 // (dynamic or wildcard) and encode or not depending on the type 4 import Helper from '@ember/component/helper'; 5 import { hrefTo } from 'ember-href-to/helpers/href-to'; 6 7 import wildcard from 'consul-ui/utils/routing/wildcard'; 8 9 import { routes } from 'consul-ui/router'; 10 11 const isWildcard = wildcard(routes); 12 13 export default Helper.extend({ 14 compute([targetRouteName, ...rest], namedArgs) { 15 if (namedArgs.params) { 16 return hrefTo(this, ...namedArgs.params); 17 } else { 18 if (isWildcard(targetRouteName)) { 19 const split = rest.map(function(item, i) { 20 return item 21 .split('/') 22 .map(encodeURIComponent) 23 .join('/'); 24 }); 25 return hrefTo(this, targetRouteName, ...split); 26 } else { 27 return hrefTo(this, targetRouteName, ...rest); 28 } 29 } 30 }, 31 });