Skip to content

Commit

Permalink
[routing-utils] Add missing fields (vercel#6872)
Browse files Browse the repository at this point in the history
* chore: add missing fields

* Update types.ts

* Update types.ts

* chore add missing as part of the schema

* test: add missing case
  • Loading branch information
Kikobeats authored Oct 21, 2021
1 parent c35c054 commit 981a76f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/routing-utils/src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export const routesSchema = {
type: 'number',
},
has: hasSchema,
missing: hasSchema,
},
},
{
Expand Down Expand Up @@ -194,6 +195,7 @@ export const rewritesSchema = {
maxLength: 4096,
},
has: hasSchema,
missing: hasSchema,
},
},
} as const;
Expand Down Expand Up @@ -232,6 +234,7 @@ export const redirectsSchema = {
maximum: 999,
},
has: hasSchema,
missing: hasSchema,
},
},
} as const;
Expand Down Expand Up @@ -273,6 +276,7 @@ export const headersSchema = {
},
},
has: hasSchema,
missing: hasSchema,
},
},
} as const;
Expand Down
4 changes: 4 additions & 0 deletions packages/routing-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type Source = {
important?: boolean;
status?: number;
has?: HasField;
missing?: HasField;
locale?: {
redirect?: Record<string, string>;
cookie?: string;
Expand Down Expand Up @@ -83,6 +84,7 @@ export interface Rewrite {
source: string;
destination: string;
has?: HasField;
missing?: HasField;
}

export interface Redirect {
Expand All @@ -91,12 +93,14 @@ export interface Redirect {
permanent?: boolean;
statusCode?: number;
has?: HasField;
missing?: HasField;
}

export interface Header {
source: string;
headers: HeaderKeyValue[];
has?: HasField;
missing?: HasField;
}

export interface HeaderKeyValue {
Expand Down
3 changes: 3 additions & 0 deletions packages/routing-utils/test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ describe('normalizeRoutes', () => {
{ type: 'query', key: 'authorized', value: 'yup' },
{ type: 'host', value: 'vercel.com' },
],
missing: [
{ type: 'header', key: 'x-middleware-subrequest', value: 'secret' },
],
},
];

Expand Down

0 comments on commit 981a76f

Please sign in to comment.