2022-11-02 10:10:29 +00:00
|
|
|
import {Redirect} from './base.js';
|
|
|
|
|
|
|
|
export class RegexRedirect extends Redirect {
|
2022-11-21 11:43:56 +00:00
|
|
|
public redirect(redirect: URL | string): string {
|
2022-11-02 10:10:29 +00:00
|
|
|
const url = redirect instanceof URL ? redirect.href : redirect;
|
|
|
|
const regex = new RegExp(this.parameters.matcherValue, 'gi');
|
2022-11-21 11:43:56 +00:00
|
|
|
return url.replace(regex, this.parameters.redirectValue);
|
2022-11-02 10:10:29 +00:00
|
|
|
}
|
|
|
|
}
|