Skip to content

Commit

Permalink
fix: Fixes request and response to include all properties
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodedrift committed Aug 23, 2024
1 parent 7a86a44 commit d80185b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-zoos-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@taskless/loader": patch
---

Ensures all request and response lua calls copy all properties
19 changes: 5 additions & 14 deletions src/lua/request.bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ export const requestFunctions: LuaBridgeBuilder<
},
setURL(url: string) {
checkLock();
current = new Request(url, {
method: current.method,
headers: current.headers,
body: current.body,
});
current = new Request(url, current);
},
getParameter(name: string) {
const url = new URL(current.url);
Expand All @@ -51,11 +47,7 @@ export const requestFunctions: LuaBridgeBuilder<
checkLock();
const url = new URL(current.url);
url.searchParams.set(name, value);
current = new Request(url.toString(), {
method: current.method,
headers: current.headers,
body: current.body,
});
current = new Request(url.toString(), current);
},
getHeader(name: string) {
return current.headers.get(name);
Expand All @@ -64,9 +56,9 @@ export const requestFunctions: LuaBridgeBuilder<
checkLock();
const headers = new Headers(current.headers);
headers.set(name, value);

current = new Request(current.url, {
method: current.method,
body: current.body,
...current,
headers,
});
},
Expand All @@ -78,8 +70,7 @@ export const requestFunctions: LuaBridgeBuilder<
// keep everything synchronous in lua, but update
// the request object as well so it stays current
current = new Request(current.url, {
method: current.method,
headers: current.headers,
...current,
body: data,
});
},
Expand Down
10 changes: 3 additions & 7 deletions src/lua/response.bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ export const responseFunctions: LuaBridgeBuilder<
// keep everything synchronous in lua, but update
// the request object as well so it stays current
current = new Response(data, {
status: current.status,
statusText: current.statusText,
headers: current.headers,
...current,
});
},
getHeader(name: string) {
Expand All @@ -51,8 +49,7 @@ export const responseFunctions: LuaBridgeBuilder<
const headers = new Headers(current.headers);
headers.set(name, value);
current = new Response(current.body, {
status: current.status,
statusText: current.statusText,
...current,
headers,
});
},
Expand All @@ -62,9 +59,8 @@ export const responseFunctions: LuaBridgeBuilder<
setStatus(status: number) {
checkLock();
current = new Response(current.body, {
...current,
status,
statusText: current.statusText,
headers: current.headers,
});
},
},
Expand Down

0 comments on commit d80185b

Please sign in to comment.