Skip to content

Commit a0e46ec

Browse files
authored
fix: stop query params persisting across page navigation (#333)
1 parent 6050e7b commit a0e46ec

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/server/plugins/engine/helpers.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,18 @@ describe('Helpers', () => {
228228
expect(h.redirect).not.toHaveBeenCalledWith(request.query.returnUrl)
229229
}
230230
)
231+
232+
it('should not forward custom query params to the next page URL', () => {
233+
request = {
234+
...request,
235+
method: 'post',
236+
query: { parcelId: 'SD5848-9205' }
237+
}
238+
239+
proceed(request, h, '/test/next-page')
240+
241+
expect(h.redirect).toHaveBeenCalledWith('/test/next-page')
242+
})
231243
})
232244

233245
describe('encodeUrl', () => {

src/server/plugins/engine/helpers.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
} from '~/src/server/plugins/engine/components/helpers/components.js'
2323
import { type FormModel } from '~/src/server/plugins/engine/models/FormModel.js'
2424
import { type PageControllerClass } from '~/src/server/plugins/engine/pageControllers/helpers/pages.js'
25-
import { stripParam } from '~/src/server/plugins/engine/pageControllers/helpers/state.js'
2625
import {
2726
type AnyFormRequest,
2827
type FormContext,
@@ -134,7 +133,7 @@ export function proceed(
134133
const response =
135134
isReturnAllowed && isPathRelative(returnUrl)
136135
? h.redirect(returnUrl)
137-
: h.redirect(redirectPath(nextUrl, stripParam(query, 'returnUrl')))
136+
: h.redirect(redirectPath(nextUrl))
138137

139138
// Redirect POST to GET to avoid resubmission
140139
return method === 'post'

0 commit comments

Comments
 (0)