diff --git a/src/common/plugin/PluginState.ts b/src/common/plugin/PluginState.ts index 60734a9a..4cbf4a97 100644 --- a/src/common/plugin/PluginState.ts +++ b/src/common/plugin/PluginState.ts @@ -51,7 +51,7 @@ export interface PluginState { clearCache: () => Promise getLocalServers: ( numServersWanted: number, - includePatterns: string[] + includePatterns?: Array ) => string[] refreshServers: () => Promise updateServers: (settings: UtxoUserSettings) => Promise @@ -209,7 +209,7 @@ export function makePluginState(settings: PluginStateSettings): PluginState { getLocalServers( numServersWanted: number, - includePatterns: string[] = [] + includePatterns: Array = [] ): string[] { return serverScores.getServers( knownServers, diff --git a/src/common/plugin/ServerScores.ts b/src/common/plugin/ServerScores.ts index 5990ad14..9a64a22a 100644 --- a/src/common/plugin/ServerScores.ts +++ b/src/common/plugin/ServerScores.ts @@ -208,7 +208,7 @@ export class ServerScores { getServers( servers: ServerList, numServersWanted: number, - includePatterns: string[] = [] + includePatterns: Array = [] ): string[] { if (servers == null || Object.keys(servers).length === 0) { return [] @@ -236,7 +236,14 @@ export class ServerScores { const filter = (server: ServerInfo): boolean => { for (const pattern of includePatterns) { // make sure that the server URL starts with the required pattern - if (server.serverUrl.indexOf(pattern) === 0) return true + if ( + typeof pattern === 'string' && + server.serverUrl.indexOf(pattern) === 0 + ) + return true + // Or make sure that the server URL matches regex + if (pattern instanceof RegExp && pattern.test(server.serverUrl)) + return true } return false }