diff --git a/examples/weather/template.html b/examples/weather/template.html index f8e442b..d8b7bff 100644 --- a/examples/weather/template.html +++ b/examples/weather/template.html @@ -1,5 +1,6 @@ + AngularJS-Server Weather Example diff --git a/lib/main.js b/lib/main.js index fc4b629..2aaeace 100644 --- a/lib/main.js +++ b/lib/main.js @@ -140,6 +140,15 @@ function makeHtmlGenerator(serverScripts, prepContext, clientScripts, template, var path = reqContext.location.path(); var search = reqContext.location.search(); + //Fixing trailing slash issue - when navigating from home to any city (ex: boston) and reload the page, somehow '\' is added to the end of location.href, which breaks the routing. + //This code will remove the trailing slash + //Taken from https://github.com/angular-ui/ui-router/issues/50#issuecomment-64895625 + var re = /(.+)(\/+)(\?.*)?$/ + if(re.test(path)) { + path = path.replace(re, '$1$3') + } + //End of fix + var matchedRoute = $route.getByPath(path, search); if (matchedRoute) {