Add the regex matcher.
This commit is contained in:
parent
93096b839a
commit
f7d292932f
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue