Skip to content

Commit 9b7682e

Browse files
authored
Merge pull request #1339 from Balastrong/feature/1338-double-check-object-string
Double check if native tostring is [object *]
2 parents 812a259 + 166caec commit 9b7682e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/adapter/templates/getStringyProps.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ export const getStringyProps = remoteFunction(function (this: unknown, maxLength
1616

1717
for (const [key, value] of Object.entries(this)) {
1818
if (typeof value === 'object' && value && !String(value.toString).includes('[native code]')) {
19-
out[key] = String(value).slice(0, maxLength);
19+
const str = String(value);
20+
if (!str.startsWith('[object ')) {
21+
out[key] = str.slice(0, maxLength);
22+
}
2023
}
2124
}
2225

@@ -25,6 +28,9 @@ export const getStringyProps = remoteFunction(function (this: unknown, maxLength
2528

2629
export const getToStringIfCustom = remoteFunction(function (this: unknown, maxLength: number) {
2730
if (typeof this === 'object' && this && !String(this.toString).includes('[native code]')) {
28-
return String(this).slice(0, maxLength);
31+
const str = String(this);
32+
if (!str.startsWith('[object ')) {
33+
return str.slice(0, maxLength);
34+
}
2935
}
3036
});

0 commit comments

Comments
 (0)