From a6db427b4188ec8709b32799d94f07afbd16cb5b Mon Sep 17 00:00:00 2001 From: saravmajestic Date: Sat, 10 Jan 2015 16:56:57 +0530 Subject: [PATCH 1/2] Fixing trailing slash issue on page reload 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 --- lib/main.js | 9 +++++++++ 1 file changed, 9 insertions(+) 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) { From feb6113e4624b67d4b5d2dbec397279177e6084d Mon Sep 17 00:00:00 2001 From: saravmajestic Date: Sat, 10 Jan 2015 16:58:51 +0530 Subject: [PATCH 2/2] Fix for angular 1.3.8 version upgrade Adding "base" tag since it is mandatory for angular 1.3.x versions --- examples/weather/template.html | 1 + 1 file changed, 1 insertion(+) 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