// inspired by http://stackoverflow.com/a/36368522

import Ember from 'ember';

export default Ember.Helper.extend({
  router: Ember.computed(function() {
    return Ember.getOwner(this).lookup('router:main');
  }),

  compute([routeName, ...routeParams]) {
    let router = this.get('router');

    var resUrl = Ember.isEmpty(routeParams) ?
      router.generate(routeName) : router.generate(routeName, routeParams[0]);
    var location = window.location;
    return  location.protocol + "//" + location.host + location.pathname + resUrl;
  }
});
