Skip to content

Commit

Permalink
Restore state option mergeArrays: false
Browse files Browse the repository at this point in the history
The types had the incorrect default so I flipped this the wrong way previously. See: hapijs/hoek#395
  • Loading branch information
colinrotherham committed Aug 8, 2024
1 parent fc930be commit bff3e9c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,7 @@ export class PageControllerBase {
/**
* deals with parsing errors and saving answers to state
*/
async handlePostRequest(
request: Request,
h: ResponseToolkit,
mergeOptions?: merge.Options
) {
async handlePostRequest(request: Request, h: ResponseToolkit) {
const { cacheService } = request.services([])
const payload = (request.payload || {}) as FormPayload
const formResult = this.validateForm(payload)
Expand Down Expand Up @@ -553,7 +549,7 @@ export class PageControllerBase {
return
}

await cacheService.mergeState(request, update, mergeOptions)
await cacheService.mergeState(request, update)
}

/**
Expand Down
10 changes: 4 additions & 6 deletions src/server/services/cacheService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@ export class CacheService {
return cached || {}
}

async mergeState(
request: Request,
value: object,
mergeOptions?: merge.Options
) {
async mergeState(request: Request, value: object) {
const key = this.Key(request)
const state = await this.getState(request)
const ttl = config.get('sessionTimeout')

merge(state, value, mergeOptions)
merge(state, value, {
mergeArrays: false
})

await this.cache.set(key, state, ttl)
return this.cache.get(key)
Expand Down

0 comments on commit bff3e9c

Please sign in to comment.