Skip to content

Commit 43e8d57

Browse files
committed
feat: sanitize redux log params
1 parent 5ab5a10 commit 43e8d57

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/redux-devtools-extension.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function logStateAction(
4949
if (isEnableLog) {
5050
const action = {
5151
type: `${namespace}/${infos.actionName}`,
52-
params: infos.params,
52+
params: filterParams(infos.params),
5353
}
5454

5555
if (infos.state) {
@@ -59,3 +59,15 @@ export function logStateAction(
5959
getDevTools().send(action, STATE)
6060
}
6161
}
62+
63+
function filterParams(params: any): any {
64+
if (params && typeof params === 'object') {
65+
if (params instanceof Event) {
66+
return `<<Event:${params.type}>>`
67+
} else if (params.nativeEvent instanceof Event) {
68+
return `<<SyntheticEvent:${params.nativeEvent.type}>>`
69+
}
70+
}
71+
72+
return params
73+
}

0 commit comments

Comments
 (0)