Skip to content

Commit e49737b

Browse files
fix: incorrect props string truncation (#508)
1 parent 77c21e2 commit e49737b

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/adapter/shared/serialize.test.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ describe("jsonify", () => {
4545
},
4646
});
4747
});
48+
49+
it("should truncate long strings", () => {
50+
const data = { foo: "start" + "foo".repeat(200) } as const;
51+
expect(jsonify(data, () => null, new Set())).to.deep.equal({
52+
foo: ("start" + "foo".repeat(100)).slice(0, 300),
53+
});
54+
});
4855
});
4956

5057
describe("cleanProps", () => {

src/adapter/shared/serialize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function jsonify(
8282
}
8383
switch (typeof data) {
8484
case "string":
85-
return data.length > 300 ? data.slice(300) : data;
85+
return data.length > 300 ? data.slice(0, 300) : data;
8686
case "bigint":
8787
return {
8888
type: "bigint",

0 commit comments

Comments
 (0)