summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/js/js.js35
1 files changed, 33 insertions, 2 deletions
diff --git a/core/js/js.js b/core/js/js.js
index 69ebabdb419..edee72ca3ca 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -2050,8 +2050,9 @@ OC.Util.History = {
*
* @param params to append to the URL, can be either a string
* or a map
+ * @param {boolean} [replace=false] whether to replace instead of pushing
*/
- pushState: function(params) {
+ _pushState: function(params, replace) {
var strParams;
if (typeof(params) === 'string') {
strParams = params;
@@ -2061,7 +2062,11 @@ OC.Util.History = {
}
if (window.history.pushState) {
var url = location.pathname + '?' + strParams;
- window.history.pushState(params, '', url);
+ if (replace) {
+ window.history.replaceState(params, '', url);
+ } else {
+ window.history.pushState(params, '', url);
+ }
}
// use URL hash for IE8
else {
@@ -2073,6 +2078,32 @@ OC.Util.History = {
},
/**
+ * Push the current URL parameters to the history stack
+ * and change the visible URL.
+ * Note: this includes a workaround for IE8/IE9 that uses
+ * the hash part instead of the search part.
+ *
+ * @param params to append to the URL, can be either a string
+ * or a map
+ */
+ pushState: function(params) {
+ return this._pushState(params, false);
+ },
+
+ /**
+ * Push the current URL parameters to the history stack
+ * and change the visible URL.
+ * Note: this includes a workaround for IE8/IE9 that uses
+ * the hash part instead of the search part.
+ *
+ * @param params to append to the URL, can be either a string
+ * or a map
+ */
+ replaceState: function(params) {
+ return this._pushState(params, true);
+ },
+
+ /**
* Add a popstate handler
*
* @param handler function