Skip to content

Commit

Permalink
fix: Append History state.headerData to url query-param is set
Browse files Browse the repository at this point in the history
  • Loading branch information
ambroisemaupate committed Sep 29, 2023
1 parent 9ffaf6e commit 0a1e35c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion lib/Rozier/src/Resources/app/Lazyload.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,31 @@ export default class Lazyload {
window.dispatchEvent(pageChangeEvent)

try {
const response = await fetch(location.href, {
let url = ''
const path = location.href.split('?')[0]
const params = new URLSearchParams(location.href.split('?')[1])
if (state.headerData) {
/**
* @param {string} key
* @param {string|number|Array<string|number>} value
*/
for (let [key, value] of Object.entries(state.headerData)) {
if (Array.isArray(value)) {
value.forEach((v, i) => {
params.append(key + '[' + i + ']', v)
})
} else {
params.set(key, value)
}
}
}
if (params.toString() !== '') {
url = path + '?' + params.toString()
} else {
url = path
}

const response = await fetch(url, {
method: 'GET',
headers: {
'X-Partial': true,
Expand Down

0 comments on commit 0a1e35c

Please sign in to comment.