Skip to content

Commit

Permalink
Merge pull request #50 from rtheunissen/master
Browse files Browse the repository at this point in the history
Fix routes with null hosts using `null` as the host in the generated URL
  • Loading branch information
aaronlord authored Feb 8, 2017
2 parents 921b609 + 72e9bab commit 2adee9d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/templates/laroute.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
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;
}

return this.getCorrectUrl(uri + qs);
},

isOtherHost: function (route){
return route.host != window.location.hostname;
return route.host && route.host != window.location.hostname;
},

replaceNamedParameters : function (uri, parameters) {
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/templates/laroute.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2adee9d

Please sign in to comment.