diff --git a/source/redirect/base.ts b/source/redirect/base.ts index 76f0549..f1da008 100644 --- a/source/redirect/base.ts +++ b/source/redirect/base.ts @@ -1,6 +1,7 @@ import {HostnameParameters} from './hostname.js'; +import {SimpleParameters} from './simple.js'; -export type RedirectParameters = HostnameParameters; +export type RedirectParameters = HostnameParameters | SimpleParameters; export type Matcher = { matchType: 'hostname'; diff --git a/source/redirect/exports.ts b/source/redirect/exports.ts index 221a387..0528f8a 100644 --- a/source/redirect/exports.ts +++ b/source/redirect/exports.ts @@ -1,9 +1,11 @@ import {HostnameRedirect} from './hostname.js'; +import {SimpleRedirect} from './simple.js'; export * from './base.js'; export * from './hostname.js'; +export * from './simple.js'; -export type Redirects = HostnameRedirect; +export type Redirects = HostnameRedirect | SimpleRedirect; export function parseRedirect

( parameters: P, diff --git a/source/redirect/simple.ts b/source/redirect/simple.ts new file mode 100644 index 0000000..d5953ae --- /dev/null +++ b/source/redirect/simple.ts @@ -0,0 +1,12 @@ +import {Redirect} from './base.js'; + +export type SimpleParameters = { + target: string; + type: 'simple'; +}; + +export class SimpleRedirect extends Redirect { + public redirect(): URL { + return new URL(this.parameters.target); + } +}