Skip to content

Commit 4034096

Browse files
committed
Made sure strings won't break
1 parent 614e7f5 commit 4034096

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/asbind-instance/bind-function.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,10 @@ export function bindExportFunction(asbindInstance, exportFunctionKey) {
226226
}
227227

228228
if (supportedType) {
229-
if (functionThis.unsafeReturnValue) {
229+
if (
230+
functionThis.unsafeReturnValue &&
231+
supportedType.getUnsafeValueFromRef
232+
) {
230233
response = supportedType.getUnsafeValueFromRef(
231234
exports,
232235
exportFunctionResponse

test/test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,12 @@ describe("asbind", () => {
658658
);
659659
});
660660

661+
it("should not break strings", () => {
662+
asbindInstance.exports.helloWorld.unsafeReturnValue = true;
663+
const response = asbindInstance.exports.helloWorld("asbind");
664+
assert.equal(response, "Hello asbind!");
665+
});
666+
661667
// TypedArrays
662668
[
663669
"Int8Array",

0 commit comments

Comments
 (0)