From 9f532fe976094d5ab5cdb6da2a58666fe67eb7d8 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 15 May 2013 15:39:28 +1200 Subject: [PATCH] BUG GridField action onclick assuming URL without "?" character Sometimes GridState URL will have a query string already appended, e.g. "?local=en_GB", but the GridField javascript assumes there won't be. The result would be an action URL like: "/my/url?locale=en_US?RelatedPage=123" which is obviously invalid. The fix is to check that "?" exists in the GridState URL and use "&" instead to connect the URLs if that's the case. --- javascript/GridField.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/javascript/GridField.js b/javascript/GridField.js index 6b372d411..ae5e81cab 100644 --- a/javascript/GridField.js +++ b/javascript/GridField.js @@ -170,8 +170,11 @@ data = window.location.search.replace(/^\?/, '') + '&' + data; } + // decide whether we should use ? or & to connect the URL + var connector = grid.data('url').indexOf('?') == -1 ? '?' : '&'; + var url = $.path.makeUrlAbsolute( - grid.data('url') + '?' + data, + grid.data('url') + connector + data, $('base').attr('href') ); @@ -215,8 +218,11 @@ data = window.location.search.replace(/^\?/, '') + '&' + data; } + // decide whether we should use ? or & to connect the URL + var connector = grid.data('url').indexOf('?') == -1 ? '?' : '&'; + window.location.href = $.path.makeUrlAbsolute( - grid.data('url') + '?' + data, + grid.data('url') + connector + data, $('base').attr('href') ); @@ -357,4 +363,4 @@ } }); }); -}(jQuery)); \ No newline at end of file +}(jQuery));