Skip to content

Commit 810040a

Browse files
vrdeTimDaub
authored andcommitted
Allow regular expressions in config file
Problem: testing the burner wallet in a local network requires to update the configuration with the IP/hostname of the development server. My IP changes depending on the network I'm in, and every time I get a new IP address I have to update the config file to match it. Moreover, if I want to test with ngrok my hostname changes all the times I start the ngrok tunneling service. Solution: local networks have specific IP ranges, so instead of pointing to a specific IP address we can use a regexp to match all IPs in that local network. We can extend this idea to all subdomains of ngrok.
1 parent 38ff965 commit 810040a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const configs = [
22
{
3-
DOMAINS: ["localhost", "10.0.0.107", "sundai.fritz.box", "192.168.178.25"],
3+
DOMAINS: ["localhost", "10.0.0.107", "sundai.fritz.box", /192\.168\..*/, /.*\.ngrok\.io/],
44
CURRENCY: {
55
CURRENCY_LIST: ["USD", "EUR", "GBP"],
66
DEFAULT_CURRENCY: "USD"
@@ -136,7 +136,12 @@ const configs = [
136136
];
137137

138138
function findConfig(hostname) {
139-
return configs.filter(({ DOMAINS }) => DOMAINS.includes(hostname));
139+
return configs.filter(
140+
({ DOMAINS }) =>
141+
DOMAINS.filter(domain =>
142+
domain instanceof RegExp ? domain.exec(hostname) : domain === hostname
143+
).length
144+
);
140145
}
141146

142147
export default function getConfig() {

0 commit comments

Comments
 (0)