Skip to content

Commit 13863af

Browse files
CoveMBericglau
andauthored
Escape encoding of special character to avoid crash of bto (#547)
Co-authored-by: Eric Lau <[email protected]>
1 parent 6789092 commit 13863af

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/ui/src/solidity/remix.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
export function remixURL(code: string, upgradeable = false): URL {
22
const remix = new URL('https://remix.ethereum.org');
3-
remix.searchParams.set('code', btoa(code).replace(/=*$/, ''));
3+
4+
const codeWithEscapedSpecialCharacters = Array.from(new TextEncoder().encode(code), b => String.fromCharCode(b)).join(
5+
'',
6+
);
7+
8+
remix.searchParams.set('code', btoa(codeWithEscapedSpecialCharacters).replace(/=*$/, ''));
9+
410
if (upgradeable) {
511
remix.searchParams.set('deployProxy', upgradeable.toString());
612
}
13+
714
return remix;
815
}

0 commit comments

Comments
 (0)