Skip to content

Commit 19cab9b

Browse files
committed
fix: make regex inclusive for local testing
1 parent f9e7ca3 commit 19cab9b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

scripts/setup-envs.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,22 @@ function processDirectory(dir, values, summary) {
100100
}
101101

102102
function validate(values) {
103-
const pk = values.PRIVATE_KEY;
104-
if (!/^0x[a-fA-F0-9]{64}$/.test(pk)) {
105-
throw new Error('PRIVATE_KEY must be 0x + 64 hex characters.');
103+
const pk = values.PRIVATE_KEY && String(values.PRIVATE_KEY).trim();
104+
if (!/^(?:0x)?[a-fA-F0-9]{64}$/.test(pk)) {
105+
throw new Error('PRIVATE_KEY must be 64 hex characters, with or without a leading 0x.');
106+
}
107+
// Normalize: ensure stored value has 0x prefix
108+
if (!pk.startsWith('0x')) {
109+
values.PRIVATE_KEY = `0x${pk}`;
110+
} else {
111+
values.PRIVATE_KEY = pk;
106112
}
107113
['CHAIN_RPC', 'PARENT_CHAIN_RPC'].forEach((k) => {
108-
if (!/^https?:\/\/\S+$/i.test(values[k])) {
114+
if (!/^https?:\/\/\S+$/i.test(String(values[k] || ''))) {
109115
throw new Error(`${k} must be an http(s) URL.`);
110116
}
111117
});
112-
if (values.L1_RPC && !/^https?:\/\/\S+$/i.test(values.L1_RPC)) {
118+
if (values.L1_RPC && !/^https?:\/\/\S+$/i.test(String(values.L1_RPC))) {
113119
throw new Error('L1_RPC must be an http(s) URL if provided.');
114120
}
115121
}

0 commit comments

Comments
 (0)