diff --git a/gruntfile.js b/gruntfile.js
index 8f26bcf..2971cfb 100644
--- a/gruntfile.js
+++ b/gruntfile.js
@@ -5,7 +5,7 @@ module.exports = function (grunt) {
uglify : {
build : {
files : {
- 'src/Lord/Laroute/templates/laroute.min.js' : 'src/Lord/Laroute/templates/laroute.js'
+ 'src/templates/laroute.min.js' : 'src/templates/laroute.js'
}
}
}
diff --git a/src/templates/laroute.js b/src/templates/laroute.js
index 872a507..f868098 100644
--- a/src/templates/laroute.js
+++ b/src/templates/laroute.js
@@ -31,7 +31,7 @@
var uri = this.replaceNamedParameters(route.uri, parameters);
var qs = this.getRouteQueryString(parameters);
- if(this.isOtherHost(route)){
+ if (this.absolute && this.isOtherHost(route)){
return "//" + route.host + "/" + uri + qs;
}
@@ -39,7 +39,7 @@
},
isOtherHost: function (route){
- return route.host != window.location.hostname;
+ return route.host && route.host != window.location.hostname;
},
replaceNamedParameters : function (uri, parameters) {
@@ -93,8 +93,9 @@
getCorrectUrl: function (uri) {
var url = this.prefix + '/' + uri.replace(/^\/?/, '');
- if(!this.absolute)
+ if ( ! this.absolute) {
return url;
+ }
return this.rootUrl.replace('/\/?$/', '') + url;
}
diff --git a/src/templates/laroute.min.js b/src/templates/laroute.min.js
index 37a7fac..2593912 100644
--- a/src/templates/laroute.min.js
+++ b/src/templates/laroute.min.js
@@ -1 +1 @@
-(function(){var a=function(){var a={absolute:$ABSOLUTE$,rootUrl:"$ROOTURL$",routes:$ROUTES$,prefix:"$PREFIX$",route:function(a,b,c){return c=c||this.getByName(a),c?this.toRoute(c,b):void 0},url:function(a,b){b=b||[];var c=a+"/"+b.join("/");return this.getCorrectUrl(c)},toRoute:function(a,b){var c=this.replaceNamedParameters(a.uri,b),d=this.getRouteQueryString(b);return this.getCorrectUrl(c+d)},replaceNamedParameters:function(a,b){return a=a.replace(/\{(.*?)\??\}/g,function(a,c){if(b.hasOwnProperty(c)){var d=b[c];return delete b[c],d}return a}),a=a.replace(/\/\{.*?\?\}/g,"")},getRouteQueryString:function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c+"="+a[c]);return b.length<1?"":"?"+b.join("&")},getByName:function(a){for(var b in this.routes)if(this.routes.hasOwnProperty(b)&&this.routes[b].name===a)return this.routes[b]},getByAction:function(a){for(var b in this.routes)if(this.routes.hasOwnProperty(b)&&this.routes[b].action===a)return this.routes[b]},getCorrectUrl:function(a){var b=this.prefix+"/"+a.replace(/^\/?/,"");return this.absolute?this.rootUrl.replace("//?$/","")+b:b}},b=function(a){if(!a)return"";var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c+'="'+a[c]+'"');return b.join(" ")},c=function(a,c,d){return c=c||a,d=b(d),'"+c+""};return{action:function(b,c){return c=c||{},a.route(b,c,a.getByAction(b))},route:function(b,c){return c=c||{},a.route(b,c)},url:function(b,c){return c=c||{},a.url(b,c)},link_to:function(a,b,d){return a=this.url(a),c(a,b,d)},link_to_route:function(a,b,d,e){var f=this.route(a,d);return c(f,b,e)},link_to_action:function(a,b,d,e){var f=this.action(a,d);return c(f,b,e)}}}.call(this);"function"==typeof define&&define.amd?define(function(){return a}):"object"==typeof module&&module.exports?module.exports=a:window.$NAMESPACE$=a}).call(this);
\ No newline at end of file
+(function(){var a=function(){var a={absolute:$ABSOLUTE$,rootUrl:"$ROOTURL$",routes:$ROUTES$,prefix:"$PREFIX$",route:function(a,b,c){if(c=c||this.getByName(a))return this.toRoute(c,b)},url:function(a,b){b=b||[];var c=a+"/"+b.join("/");return this.getCorrectUrl(c)},toRoute:function(a,b){var c=this.replaceNamedParameters(a.uri,b),d=this.getRouteQueryString(b);return this.absolute&&this.isOtherHost(a)?"//"+a.host+"/"+c+d:this.getCorrectUrl(c+d)},isOtherHost:function(a){return a.host&&a.host!=window.location.hostname},replaceNamedParameters:function(a,b){return a=a.replace(/\{(.*?)\??\}/g,function(a,c){if(b.hasOwnProperty(c)){var d=b[c];return delete b[c],d}return a}),a=a.replace(/\/\{.*?\?\}/g,"")},getRouteQueryString:function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c+"="+a[c]);return b.length<1?"":"?"+b.join("&")},getByName:function(a){for(var b in this.routes)if(this.routes.hasOwnProperty(b)&&this.routes[b].name===a)return this.routes[b]},getByAction:function(a){for(var b in this.routes)if(this.routes.hasOwnProperty(b)&&this.routes[b].action===a)return this.routes[b]},getCorrectUrl:function(a){var b=this.prefix+"/"+a.replace(/^\/?/,"");return this.absolute?this.rootUrl.replace("//?$/","")+b:b}},b=function(a){if(!a)return"";var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c+'="'+a[c]+'"');return b.join(" ")},c=function(a,c,d){return c=c||a,d=b(d),'"+c+""};return{action:function(b,c){return c=c||{},a.route(b,c,a.getByAction(b))},route:function(b,c){return c=c||{},a.route(b,c)},url:function(b,c){return c=c||{},a.url(b,c)},link_to:function(a,b,d){return a=this.url(a),c(a,b,d)},link_to_route:function(a,b,d,e){var f=this.route(a,d);return c(f,b,e)},link_to_action:function(a,b,d,e){var f=this.action(a,d);return c(f,b,e)}}}.call(this);"function"==typeof define&&define.amd?define(function(){return a}):"object"==typeof module&&module.exports?module.exports=a:window.$NAMESPACE$=a}).call(this);
\ No newline at end of file