summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-03-24 11:51:58 +0100
committerJoas Schilling <coding@schilljs.com>2017-03-24 11:51:58 +0100
commit34f0ad4ebef9c492210c482f505b411d8ad6e004 (patch)
treedced2519a8780a1cb8827db4f5afea815161c5a6
parent35d3a082f2a7256c104894faf6820a1410a0a38e (diff)
downloadnextcloud-server-34f0ad4ebef9c492210c482f505b411d8ad6e004.tar.gz
nextcloud-server-34f0ad4ebef9c492210c482f505b411d8ad6e004.zip
Allow to push a non-query URL to the browser history
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--core/js/js.js24
1 files changed, 15 insertions, 9 deletions
diff --git a/core/js/js.js b/core/js/js.js
index 370e68f5602..683f73c0d1f 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -2005,11 +2005,13 @@ OC.Util.History = {
* 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
+ * @param {Object|string} params to append to the URL, can be either a string
* or a map
+ * @param {string} [url] URL to be used, otherwise the current URL will be used,
+ * using the params as query string
* @param {boolean} [replace=false] whether to replace instead of pushing
*/
- _pushState: function(params, replace) {
+ _pushState: function(params, url, replace) {
var strParams;
if (typeof(params) === 'string') {
strParams = params;
@@ -2018,7 +2020,7 @@ OC.Util.History = {
strParams = OC.buildQueryString(params);
}
if (window.history.pushState) {
- var url = location.pathname + '?' + strParams;
+ url = url || location.pathname + '?' + strParams;
// Workaround for bug with SVG and window.history.pushState on Firefox < 51
// https://bugzilla.mozilla.org/show_bug.cgi?id=652991
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
@@ -2053,11 +2055,13 @@ OC.Util.History = {
* 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
+ * @param {Object|string} params to append to the URL, can be either a string
* or a map
+ * @param {string} [url] URL to be used, otherwise the current URL will be used,
+ * using the params as query string
*/
- pushState: function(params) {
- return this._pushState(params, false);
+ pushState: function(params, url) {
+ return this._pushState(params, url, false);
},
/**
@@ -2066,11 +2070,13 @@ OC.Util.History = {
* 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
+ * @param {Object|string} params to append to the URL, can be either a string
* or a map
+ * @param {string} [url] URL to be used, otherwise the current URL will be used,
+ * using the params as query string
*/
- replaceState: function(params) {
- return this._pushState(params, true);
+ replaceState: function(params, url) {
+ return this._pushState(params, url, true);
},
/**