Add SimpleRedirect.
This commit is contained in:
parent
263c0497f3
commit
1c7d4ca34b
|
@ -1,6 +1,7 @@
|
||||||
import {HostnameParameters} from './hostname.js';
|
import {HostnameParameters} from './hostname.js';
|
||||||
|
import {SimpleParameters} from './simple.js';
|
||||||
|
|
||||||
export type RedirectParameters = HostnameParameters;
|
export type RedirectParameters = HostnameParameters | SimpleParameters;
|
||||||
|
|
||||||
export type Matcher = {
|
export type Matcher = {
|
||||||
matchType: 'hostname';
|
matchType: 'hostname';
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import {HostnameRedirect} from './hostname.js';
|
import {HostnameRedirect} from './hostname.js';
|
||||||
|
import {SimpleRedirect} from './simple.js';
|
||||||
|
|
||||||
export * from './base.js';
|
export * from './base.js';
|
||||||
export * from './hostname.js';
|
export * from './hostname.js';
|
||||||
|
export * from './simple.js';
|
||||||
|
|
||||||
export type Redirects = HostnameRedirect;
|
export type Redirects = HostnameRedirect | SimpleRedirect;
|
||||||
|
|
||||||
export function parseRedirect<P extends Redirects['parameters']>(
|
export function parseRedirect<P extends Redirects['parameters']>(
|
||||||
parameters: P,
|
parameters: P,
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
import {Redirect} from './base.js';
|
||||||
|
|
||||||
|
export type SimpleParameters = {
|
||||||
|
target: string;
|
||||||
|
type: 'simple';
|
||||||
|
};
|
||||||
|
|
||||||
|
export class SimpleRedirect extends Redirect<SimpleParameters> {
|
||||||
|
public redirect(): URL {
|
||||||
|
return new URL(this.parameters.target);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue