Skip to content

Commit

Permalink
Code refactor (#63391)
Browse files Browse the repository at this point in the history
Two small changes. There's no need to check `payload === undefined` as
it will always be a string. At the other place we can reuse the global
`textEncoder` instance.

Closes NEXT-2830
  • Loading branch information
shuding authored Mar 18, 2024
1 parent 0593028 commit 3919258
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions packages/next/src/server/app-render/action-encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ async function decodeActionBoundArg(actionId: string, arg: string) {
const originalPayload = atob(arg)
const ivValue = originalPayload.slice(0, 16)
const payload = originalPayload.slice(16)
if (payload === undefined) {
throw new Error('Invalid Server Action payload.')
}

const decrypted = textDecoder.decode(
await decrypt(key, stringToUint8Array(ivValue), stringToUint8Array(payload))
Expand Down Expand Up @@ -104,7 +101,7 @@ export async function decryptActionBoundArgs(
const deserialized = await createFromReadableStream(
new ReadableStream({
start(controller) {
controller.enqueue(new TextEncoder().encode(decryped))
controller.enqueue(textEncoder.encode(decryped))
controller.close()
},
}),
Expand Down

0 comments on commit 3919258

Please sign in to comment.