Skip to content

Commit

Permalink
Merge pull request austintgriffith#243 from leapdao/feat/regex-in-config
Browse files Browse the repository at this point in the history
Allow regular expressions in config file
  • Loading branch information
TimDaub authored Aug 6, 2019
2 parents 38ff965 + 810040a commit f2510d9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const configs = [
{
DOMAINS: ["localhost", "10.0.0.107", "sundai.fritz.box", "192.168.178.25"],
DOMAINS: ["localhost", "10.0.0.107", "sundai.fritz.box", /192\.168\..*/, /.*\.ngrok\.io/],
CURRENCY: {
CURRENCY_LIST: ["USD", "EUR", "GBP"],
DEFAULT_CURRENCY: "USD"
Expand Down Expand Up @@ -136,7 +136,12 @@ const configs = [
];

function findConfig(hostname) {
return configs.filter(({ DOMAINS }) => DOMAINS.includes(hostname));
return configs.filter(
({ DOMAINS }) =>
DOMAINS.filter(domain =>
domain instanceof RegExp ? domain.exec(hostname) : domain === hostname
).length
);
}

export default function getConfig() {
Expand Down

0 comments on commit f2510d9

Please sign in to comment.