Skip to content

Commit d180502

Browse files
committed
Fix repeating of persistent parameters in url
1 parent 0b933a8 commit d180502

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

assets/dist/datagrid.js

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -204,25 +204,32 @@ document.addEventListener('change', function(e) {
204204

205205

206206
window.datagridSerializeUrl = function(obj, prefix) {
207-
var str = [];
208-
for(var p in obj) {
209-
if (obj.hasOwnProperty(p)) {
210-
var k = prefix ? prefix + "[" + p + "]" : p, v = obj[p];
211-
if (v !== null && v !== "") {
212-
if (typeof v == "object") {
213-
var r = window.datagridSerializeUrl(v, k);
214-
if (r) {
215-
str.push(r);
216-
}
217-
} else {
218-
str.push(encodeURIComponent(k) + "=" + encodeURIComponent(v));
219-
}
220-
}
221-
}
222-
}
223-
return str.join("&");
224-
}
225-
;
207+
var str = [];
208+
let urlPathForPersistentChecking = window.location.pathname;
209+
210+
for (var p in obj) {
211+
if (obj.hasOwnProperty(p)) {
212+
var k = prefix ? prefix + "[" + p + "]" : p, v = obj[p];
213+
if (v !== null && v !== "") {
214+
// fix for persistent nette parameters
215+
if (urlPathForPersistentChecking.includes('/' + v)) {
216+
urlPathForPersistentChecking = urlPathForPersistentChecking.replace('/' + v, '');
217+
continue;
218+
}
219+
if (typeof v == "object") {
220+
var r = window.datagridSerializeUrl(v, k);
221+
if (r) {
222+
str.push(r);
223+
}
224+
} else {
225+
str.push(encodeURIComponent(k) + "=" + encodeURIComponent(v));
226+
}
227+
}
228+
}
229+
}
230+
231+
return str.join("&");
232+
};
226233

227234
datagridSortable = function() {
228235
if (typeof $.fn.sortable === 'undefined') {

0 commit comments

Comments
 (0)