Skip to content
This repository
Browse code

MINOR Normalize trailing slashes in X-ControllerURL handling to avoid…

… double requests caused by SS_HTTPRequest modifying the original URL (removing trailing slash etc)
  • Loading branch information...
commit ac6f9e998750a8e4bfaf74927390b97680a2756b 1 parent c2b7416
Ingo Schommer authored March 30, 2012

Showing 1 changed file with 6 additions and 2 deletions. Show diff stats Hide diff stats

  1. 8  admin/javascript/LeftAndMain.js
8  admin/javascript/LeftAndMain.js
@@ -38,8 +38,12 @@ jQuery.noConflict();
38 38
 				// Simulates a redirect on an ajax response - just exchange the URL without re-requesting it.
39 39
 				// Causes non-pushState browser to re-request the URL, so ignore for those.
40 40
 				if(window.History.enabled && !History.emulated.pushState) {
41  
-					var url = xmlhttp.getResponseHeader('X-ControllerURL');
42  
-					if(url) window.History.replaceState({}, '', url);
  41
+					var url = xhr.getResponseHeader('X-ControllerURL');
  42
+					// Normalize trailing slashes in URL to work around routing weirdnesses in SS_HTTPRequest.
  43
+					var isSame = (url && History.getPageUrl().replace(/\/+$/, '') == url.replace(/\/+$/, ''));
  44
+					if(isSame) {
  45
+						window.History.replaceState({}, '', url);
  46
+					}
43 47
 				}
44 48
 			},
45 49
 			error: function(xmlhttp, status, error) {

0 notes on commit ac6f9e9

Please sign in to comment.
Something went wrong with that request. Please try again.