Skip to content

Commit

Permalink
fix bug with dynamic origin modifying default value
Browse files Browse the repository at this point in the history
  • Loading branch information
adraffy committed Oct 14, 2024
1 parent 76431a0 commit c90249d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
5 changes: 2 additions & 3 deletions dist/serve.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,13 @@ function serve(ezccip, {
for await (let x of req) v.push(x);
let { sender, data: calldata } = JSON.parse(Buffer.concat(v));
let match = url.match(/\/(0x[a-f0-9]{40})(?:\b|\/|\?)/i);
origin = match ? match[1] : parseOrigin(url) || origin;
let { data, history } = await ezccip.handleRead(sender, calldata, {
...a,
origin,
url,
ip,
protocol,
signingKey
signingKey,
origin: match ? match[1] : parseOrigin(url) || origin
});
log?.(ip, url, history.toString());
write_json(reply, { data });
Expand Down
5 changes: 2 additions & 3 deletions dist/serve.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ function serve(ezccip, {
for await (let x of req) v.push(x);
let { sender, data: calldata } = JSON.parse(Buffer.concat(v));
let match = url.match(/\/(0x[a-f0-9]{40})(?:\b|\/|\?)/i);
origin = match ? match[1] : parseOrigin(url) || origin;
let { data, history } = await ezccip.handleRead(sender, calldata, {
...a,
origin,
url,
ip,
protocol,
signingKey
signingKey,
origin: match ? match[1] : parseOrigin(url) || origin
});
log?.(ip, url, history.toString());
write_json(reply, { data });
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@resolverworks/ezccip",
"version": "0.0.19",
"version": "0.0.20",
"type": "module",
"scripts": {
"test": "node test/all.js",
Expand Down
4 changes: 2 additions & 2 deletions src/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export function serve(ezccip, {
for await (let x of req) v.push(x);
let {sender, data: calldata} = JSON.parse(Buffer.concat(v));
let match = url.match(/\/(0x[a-f0-9]{40})(?:\b|\/|\?)/i);
origin = match ? match[1] : (parseOrigin(url) || origin);
let {data, history} = await ezccip.handleRead(sender, calldata, {
...a, origin, url, ip, protocol, signingKey,
...a, url, ip, protocol, signingKey,
origin: match ? match[1] : (parseOrigin(url) || origin)
});
log?.(ip, url, history.toString());
write_json(reply, {data});
Expand Down

0 comments on commit c90249d

Please sign in to comment.