diff --git a/source/redirect/base.ts b/source/redirect/base.ts index ae20038..f19c8ee 100644 --- a/source/redirect/base.ts +++ b/source/redirect/base.ts @@ -1,6 +1,6 @@ import {customAlphabet} from 'nanoid'; -export const matcherTypes = ['hostname'] as const; +export const matcherTypes = ['hostname', 'regex'] as const; export const redirectTypes = ['hostname', 'simple'] as const; export type MatcherType = typeof matcherTypes[number]; @@ -42,6 +42,11 @@ export abstract class Redirect { return hostname === this.parameters.matcherValue; } + if (this.parameters.matcherType === 'regex') { + const regex = new RegExp(this.parameters.matcherValue, 'gi'); + return regex.test(url.href); + } + return false; }