Skip to content

Commit 141f0a0

Browse files
feat(wrapped-keys-lit-actions): LIT-3959 - Ensure string values are not escaped using JSON.stringify() in litActionHandler()
1 parent f8dc375 commit 141f0a0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/wrapped-keys-lit-actions/src/lib/litActionHandler.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import { AbortError } from './abortError';
55
export async function litActionHandler(actionFunc) {
66
try {
77
const litActionResult = await actionFunc();
8-
Lit.Actions.setResponse({ response: JSON.stringify(litActionResult) });
8+
// Don't re-stringify a string; we don't want to double-escape it
9+
const response =
10+
typeof litActionResult === 'string'
11+
? litActionResult
12+
: JSON.stringify(litActionResult);
13+
14+
Lit.Actions.setResponse({ response });
915
} catch (err) {
1016
// AbortError means exit immediately and do _NOT_ set a response
1117
// Nested code should really only throw this in cases where using e.g. `decryptToSingleNode`

0 commit comments

Comments
 (0)