Skip to content

Commit 4dec30e

Browse files
committed
fix: validate parseInt result in getTokenFromUrl
parseInt could return NaN for invalid chainId strings without any indication of error. Now validates and throws an error if chainId is not a valid number.
1 parent 5852ccc commit 4dec30e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎packages/frames.js/src/getTokenFromUrl.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ export function getTokenFromUrl(url: string): ParsedToken {
1414
throw new Error("Invalid token URL");
1515
}
1616

17+
const parsedChainId = parseInt(chainId);
18+
19+
if (Number.isNaN(parsedChainId)) {
20+
throw new Error("Invalid token URL: chainId is not a valid number");
21+
}
22+
1723
return {
1824
namespace,
19-
chainId: parseInt(chainId),
25+
chainId: parsedChainId,
2026
address,
2127
tokenId: tokenId || undefined,
2228
};

0 commit comments

Comments
 (0)