Skip to content

Commit

Permalink
Made sure strings won't break
Browse files Browse the repository at this point in the history
  • Loading branch information
torch2424 committed Oct 9, 2020
1 parent 614e7f5 commit 4034096
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/asbind-instance/bind-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,10 @@ export function bindExportFunction(asbindInstance, exportFunctionKey) {
}

if (supportedType) {
if (functionThis.unsafeReturnValue) {
if (
functionThis.unsafeReturnValue &&
supportedType.getUnsafeValueFromRef
) {
response = supportedType.getUnsafeValueFromRef(
exports,
exportFunctionResponse
Expand Down
6 changes: 6 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,12 @@ describe("asbind", () => {
);
});

it("should not break strings", () => {
asbindInstance.exports.helloWorld.unsafeReturnValue = true;
const response = asbindInstance.exports.helloWorld("asbind");
assert.equal(response, "Hello asbind!");
});

// TypedArrays
[
"Int8Array",
Expand Down

0 comments on commit 4034096

Please sign in to comment.