@netlify/plugin-nextjs 4.30.3-als.0 → 4.30.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/helpers/edge.js
CHANGED
|
@@ -36,18 +36,12 @@ const preamble = /* js */ `
|
|
|
36
36
|
import {
|
|
37
37
|
decode as _base64Decode,
|
|
38
38
|
} from "https://deno.land/std@0.159.0/encoding/base64.ts";
|
|
39
|
-
|
|
40
|
-
import { AsyncLocalStorage } from "https://raw.githubusercontent.com/crowlKats/deno_std/asynclocalstorage/node/async_hooks.ts";
|
|
41
|
-
|
|
42
39
|
// Deno defines "window", but naughty libraries think this means it's a browser
|
|
43
40
|
delete globalThis.window
|
|
44
41
|
globalThis.process = { env: {...Deno.env.toObject(), NEXT_RUNTIME: 'edge', 'NEXT_PRIVATE_MINIMAL_MODE': '1' } }
|
|
45
42
|
globalThis.EdgeRuntime = "netlify-edge"
|
|
46
43
|
let _ENTRIES = {}
|
|
47
44
|
|
|
48
|
-
// Next.js expects this as a global
|
|
49
|
-
globalThis.AsyncLocalStorage = AsyncLocalStorage
|
|
50
|
-
|
|
51
45
|
// Next.js uses this extension to the Headers API implemented by Cloudflare workerd
|
|
52
46
|
if(!('getAll' in Headers.prototype)) {
|
|
53
47
|
Headers.prototype.getAll = function getAll(name) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/plugin-nextjs",
|
|
3
|
-
"version": "4.30.3
|
|
3
|
+
"version": "4.30.3",
|
|
4
4
|
"description": "Run Next.js seamlessly on Netlify",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@types/jest": "^27.4.1",
|
|
42
42
|
"@types/merge-stream": "^1.1.2",
|
|
43
43
|
"@types/node": "^17.0.25",
|
|
44
|
-
"next": "^13.
|
|
44
|
+
"next": "^13.0.7",
|
|
45
45
|
"npm-run-all": "^4.1.5",
|
|
46
46
|
"typescript": "^4.6.3"
|
|
47
47
|
},
|
|
@@ -42,6 +42,7 @@ export type Rewrite = {
|
|
|
42
42
|
basePath?: false
|
|
43
43
|
locale?: false
|
|
44
44
|
has?: RouteHas[]
|
|
45
|
+
missing?: RouteHas[]
|
|
45
46
|
regex: string
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -51,6 +52,7 @@ export type Header = {
|
|
|
51
52
|
locale?: false
|
|
52
53
|
headers: Array<{ key: string; value: string }>
|
|
53
54
|
has?: RouteHas[]
|
|
55
|
+
missing?: RouteHas[]
|
|
54
56
|
regex: string
|
|
55
57
|
}
|
|
56
58
|
export type Redirect = {
|
|
@@ -59,6 +61,7 @@ export type Redirect = {
|
|
|
59
61
|
basePath?: false
|
|
60
62
|
locale?: false
|
|
61
63
|
has?: RouteHas[]
|
|
64
|
+
missing?: RouteHas[]
|
|
62
65
|
statusCode?: number
|
|
63
66
|
permanent?: boolean
|
|
64
67
|
regex: string
|
|
@@ -138,11 +141,16 @@ export function parseUrl(url: string): ParsedUrl {
|
|
|
138
141
|
|
|
139
142
|
// prepare-destination.ts
|
|
140
143
|
// Changed to use WHATWG Fetch Request instead of IncomingMessage
|
|
141
|
-
export function matchHas(
|
|
144
|
+
export function matchHas(
|
|
145
|
+
req: Pick<Request, 'headers' | 'url'>,
|
|
146
|
+
query: Params,
|
|
147
|
+
has: RouteHas[] = [],
|
|
148
|
+
missing: RouteHas[] = [],
|
|
149
|
+
): false | Params {
|
|
142
150
|
const params: Params = {}
|
|
143
151
|
const cookies = getCookies(req.headers)
|
|
144
152
|
const url = new URL(req.url)
|
|
145
|
-
const
|
|
153
|
+
const hasMatch = (hasItem: RouteHas) => {
|
|
146
154
|
let value: undefined | string | null
|
|
147
155
|
let key = hasItem.key
|
|
148
156
|
|
|
@@ -189,7 +197,9 @@ export function matchHas(req: Pick<Request, 'headers' | 'url'>, has: RouteHas[],
|
|
|
189
197
|
}
|
|
190
198
|
}
|
|
191
199
|
return false
|
|
192
|
-
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const allMatch = has.every((item) => hasMatch(item)) && !missing.some((item) => hasMatch(item))
|
|
193
203
|
|
|
194
204
|
if (allMatch) {
|
|
195
205
|
return params
|
|
@@ -371,6 +381,7 @@ export interface MiddlewareMatcher {
|
|
|
371
381
|
regexp: string
|
|
372
382
|
locale?: false
|
|
373
383
|
has?: RouteHas[]
|
|
384
|
+
missing?: RouteHas[]
|
|
374
385
|
}
|
|
375
386
|
|
|
376
387
|
export function getMiddlewareRouteMatcher(matchers: MiddlewareMatcher[]): MiddlewareRouteMatch {
|
|
@@ -381,8 +392,8 @@ export function getMiddlewareRouteMatcher(matchers: MiddlewareMatcher[]): Middle
|
|
|
381
392
|
continue
|
|
382
393
|
}
|
|
383
394
|
|
|
384
|
-
if (matcher.has) {
|
|
385
|
-
const hasParams = matchHas(req, matcher.has,
|
|
395
|
+
if (matcher.has || matcher.missing) {
|
|
396
|
+
const hasParams = matchHas(req, query, matcher.has, matcher.missing)
|
|
386
397
|
if (!hasParams) {
|
|
387
398
|
continue
|
|
388
399
|
}
|