@qwik.dev/router 2.0.0-beta.5 → 2.0.0-beta.7
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/adapters/static/vite.d.ts +1 -1
- package/lib/adapters/azure-swa/vite/index.d.ts +2 -2
- package/lib/adapters/bun-server/vite/index.d.ts +2 -2
- package/lib/adapters/cloud-run/vite/index.d.ts +2 -2
- package/lib/adapters/cloudflare-pages/vite/index.d.ts +2 -2
- package/lib/adapters/deno-server/vite/index.d.ts +2 -2
- package/lib/adapters/netlify-edge/vite/index.cjs +1 -0
- package/lib/adapters/netlify-edge/vite/index.d.ts +2 -2
- package/lib/adapters/netlify-edge/vite/index.mjs +1 -0
- package/lib/adapters/node-server/vite/index.d.ts +2 -2
- package/lib/adapters/shared/vite/index.cjs +88 -128
- package/lib/adapters/shared/vite/index.d.ts +9 -15
- package/lib/adapters/shared/vite/index.mjs +88 -124
- package/lib/adapters/{static → ssg}/vite/index.cjs +95 -124
- package/lib/adapters/ssg/vite/index.d.ts +13 -0
- package/lib/adapters/{static → ssg}/vite/index.mjs +93 -123
- package/lib/adapters/vercel-edge/vite/index.d.ts +2 -2
- package/lib/index.d.ts +161 -48
- package/lib/index.qwik.cjs +86 -23
- package/lib/index.qwik.mjs +88 -25
- package/lib/middleware/aws-lambda/index.d.ts +3 -2
- package/lib/middleware/aws-lambda/index.mjs +2 -4
- package/lib/middleware/azure-swa/index.mjs +6 -6
- package/lib/middleware/bun/index.mjs +4 -6
- package/lib/middleware/cloudflare-pages/index.mjs +4 -6
- package/lib/middleware/deno/index.mjs +8 -7
- package/lib/middleware/firebase/index.mjs +1 -3
- package/lib/middleware/netlify-edge/index.mjs +7 -6
- package/lib/middleware/node/index.cjs +4 -8
- package/lib/middleware/node/index.mjs +7 -7
- package/lib/middleware/request-handler/index.cjs +331 -268
- package/lib/middleware/request-handler/index.d.ts +56 -49
- package/lib/middleware/request-handler/index.mjs +335 -264
- package/lib/middleware/vercel-edge/index.mjs +7 -6
- package/lib/modules.d.ts +4 -12
- package/lib/{static → ssg}/deno.mjs +1 -1
- package/lib/{static → ssg}/index.cjs +1 -1
- package/lib/{static → ssg}/index.d.ts +17 -17
- package/lib/{static → ssg}/index.mjs +1 -1
- package/lib/{static → ssg}/node.cjs +16 -16
- package/lib/{static → ssg}/node.mjs +15 -15
- package/lib/vite/index.cjs +10260 -10437
- package/lib/vite/index.mjs +8220 -8387
- package/modules.d.ts +4 -12
- package/package.json +19 -8
- package/ssg.d.ts +2 -0
- package/static.d.ts +1 -1
- package/lib/adapters/static/vite/index.d.ts +0 -10
- package/middleware/request-handler/generated/not-found-paths.ts +0 -7
- package/middleware/request-handler/generated/static-paths.ts +0 -35
|
@@ -1,231 +1,3 @@
|
|
|
1
|
-
// packages/qwik-router/src/middleware/request-handler/error-handler.ts
|
|
2
|
-
var ServerError = class extends Error {
|
|
3
|
-
constructor(status, data) {
|
|
4
|
-
super(typeof data === "string" ? data : void 0);
|
|
5
|
-
this.status = status;
|
|
6
|
-
this.data = data;
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
function getErrorHtml(status, e) {
|
|
10
|
-
let message = "Server Error";
|
|
11
|
-
if (e != null) {
|
|
12
|
-
if (typeof e.message === "string") {
|
|
13
|
-
message = e.message;
|
|
14
|
-
} else {
|
|
15
|
-
message = String(e);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return `<html>` + minimalHtmlResponse(status, message) + `</html>`;
|
|
19
|
-
}
|
|
20
|
-
function minimalHtmlResponse(status, message) {
|
|
21
|
-
if (typeof status !== "number") {
|
|
22
|
-
status = 500;
|
|
23
|
-
}
|
|
24
|
-
if (typeof message === "string") {
|
|
25
|
-
message = escapeHtml(message);
|
|
26
|
-
} else {
|
|
27
|
-
message = "";
|
|
28
|
-
}
|
|
29
|
-
const width = typeof message === "string" ? "600px" : "300px";
|
|
30
|
-
const color = status >= 500 ? COLOR_500 : COLOR_400;
|
|
31
|
-
return `
|
|
32
|
-
<head>
|
|
33
|
-
<meta charset="utf-8">
|
|
34
|
-
<meta http-equiv="Status" content="${status}">
|
|
35
|
-
<title>${status} ${message}</title>
|
|
36
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
37
|
-
<style>
|
|
38
|
-
body { color: ${color}; background-color: #fafafa; padding: 30px; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif; }
|
|
39
|
-
p { max-width: ${width}; margin: 60px auto 30px auto; background: white; border-radius: 4px; box-shadow: 0px 0px 50px -20px ${color}; overflow: hidden; }
|
|
40
|
-
strong { display: inline-block; padding: 15px; background: ${color}; color: white; }
|
|
41
|
-
span { display: inline-block; padding: 15px; }
|
|
42
|
-
</style>
|
|
43
|
-
</head>
|
|
44
|
-
<body><p><strong>${status}</strong> <span>${message}</span></p></body>
|
|
45
|
-
`;
|
|
46
|
-
}
|
|
47
|
-
var ESCAPE_HTML = /[&<>]/g;
|
|
48
|
-
var escapeHtml = (s) => {
|
|
49
|
-
return s.replace(ESCAPE_HTML, (c) => {
|
|
50
|
-
switch (c) {
|
|
51
|
-
case "&":
|
|
52
|
-
return "&";
|
|
53
|
-
case "<":
|
|
54
|
-
return "<";
|
|
55
|
-
case ">":
|
|
56
|
-
return ">";
|
|
57
|
-
default:
|
|
58
|
-
return "";
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
var COLOR_400 = "#006ce9";
|
|
63
|
-
var COLOR_500 = "#713fc2";
|
|
64
|
-
|
|
65
|
-
// packages/qwik-router/src/middleware/request-handler/cookie.ts
|
|
66
|
-
var SAMESITE = {
|
|
67
|
-
lax: "Lax",
|
|
68
|
-
Lax: "Lax",
|
|
69
|
-
None: "None",
|
|
70
|
-
none: "None",
|
|
71
|
-
strict: "Strict",
|
|
72
|
-
Strict: "Strict"
|
|
73
|
-
};
|
|
74
|
-
var UNIT = {
|
|
75
|
-
seconds: 1,
|
|
76
|
-
minutes: 1 * 60,
|
|
77
|
-
hours: 1 * 60 * 60,
|
|
78
|
-
days: 1 * 60 * 60 * 24,
|
|
79
|
-
weeks: 1 * 60 * 60 * 24 * 7
|
|
80
|
-
};
|
|
81
|
-
var createSetCookieValue = (cookieName, cookieValue, options) => {
|
|
82
|
-
const c = [`${cookieName}=${cookieValue}`];
|
|
83
|
-
if (typeof options.domain === "string") {
|
|
84
|
-
c.push(`Domain=${options.domain}`);
|
|
85
|
-
}
|
|
86
|
-
if (typeof options.maxAge === "number") {
|
|
87
|
-
c.push(`Max-Age=${options.maxAge}`);
|
|
88
|
-
} else if (Array.isArray(options.maxAge)) {
|
|
89
|
-
c.push(`Max-Age=${options.maxAge[0] * UNIT[options.maxAge[1]]}`);
|
|
90
|
-
} else if (typeof options.expires === "number" || typeof options.expires == "string") {
|
|
91
|
-
c.push(`Expires=${options.expires}`);
|
|
92
|
-
} else if (options.expires instanceof Date) {
|
|
93
|
-
c.push(`Expires=${options.expires.toUTCString()}`);
|
|
94
|
-
}
|
|
95
|
-
if (options.httpOnly) {
|
|
96
|
-
c.push("HttpOnly");
|
|
97
|
-
}
|
|
98
|
-
if (typeof options.path === "string") {
|
|
99
|
-
c.push(`Path=${options.path}`);
|
|
100
|
-
}
|
|
101
|
-
const sameSite = resolveSameSite(options.sameSite);
|
|
102
|
-
if (sameSite) {
|
|
103
|
-
c.push(`SameSite=${sameSite}`);
|
|
104
|
-
}
|
|
105
|
-
if (options.secure) {
|
|
106
|
-
c.push("Secure");
|
|
107
|
-
}
|
|
108
|
-
return c.join("; ");
|
|
109
|
-
};
|
|
110
|
-
function tryDecodeUriComponent(str) {
|
|
111
|
-
try {
|
|
112
|
-
return decodeURIComponent(str);
|
|
113
|
-
} catch {
|
|
114
|
-
return str;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
var parseCookieString = (cookieString) => {
|
|
118
|
-
const cookie = {};
|
|
119
|
-
if (typeof cookieString === "string" && cookieString !== "") {
|
|
120
|
-
const cookieSegments = cookieString.split(";");
|
|
121
|
-
for (const cookieSegment of cookieSegments) {
|
|
122
|
-
const separatorIndex = cookieSegment.indexOf("=");
|
|
123
|
-
if (separatorIndex !== -1) {
|
|
124
|
-
cookie[tryDecodeUriComponent(cookieSegment.slice(0, separatorIndex).trim())] = tryDecodeUriComponent(cookieSegment.slice(separatorIndex + 1).trim());
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return cookie;
|
|
129
|
-
};
|
|
130
|
-
function resolveSameSite(sameSite) {
|
|
131
|
-
if (sameSite === true) {
|
|
132
|
-
return "Strict";
|
|
133
|
-
}
|
|
134
|
-
if (sameSite === false) {
|
|
135
|
-
return "None";
|
|
136
|
-
}
|
|
137
|
-
if (sameSite) {
|
|
138
|
-
return SAMESITE[sameSite];
|
|
139
|
-
}
|
|
140
|
-
return void 0;
|
|
141
|
-
}
|
|
142
|
-
var REQ_COOKIE = Symbol("request-cookies");
|
|
143
|
-
var RES_COOKIE = Symbol("response-cookies");
|
|
144
|
-
var LIVE_COOKIE = Symbol("live-cookies");
|
|
145
|
-
var Cookie = class {
|
|
146
|
-
[REQ_COOKIE];
|
|
147
|
-
[RES_COOKIE] = {};
|
|
148
|
-
[LIVE_COOKIE] = {};
|
|
149
|
-
appendCounter = 0;
|
|
150
|
-
constructor(cookieString) {
|
|
151
|
-
this[REQ_COOKIE] = parseCookieString(cookieString);
|
|
152
|
-
this[LIVE_COOKIE] = { ...this[REQ_COOKIE] };
|
|
153
|
-
}
|
|
154
|
-
get(cookieName, live = true) {
|
|
155
|
-
const value = this[live ? LIVE_COOKIE : REQ_COOKIE][cookieName];
|
|
156
|
-
if (!value) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
return {
|
|
160
|
-
value,
|
|
161
|
-
json() {
|
|
162
|
-
return JSON.parse(value);
|
|
163
|
-
},
|
|
164
|
-
number() {
|
|
165
|
-
return Number(value);
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
getAll(live = true) {
|
|
170
|
-
return Object.keys(this[live ? LIVE_COOKIE : REQ_COOKIE]).reduce(
|
|
171
|
-
(cookies, cookieName) => {
|
|
172
|
-
cookies[cookieName] = this.get(cookieName);
|
|
173
|
-
return cookies;
|
|
174
|
-
},
|
|
175
|
-
{}
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
has(cookieName, live = true) {
|
|
179
|
-
return !!this[live ? LIVE_COOKIE : REQ_COOKIE][cookieName];
|
|
180
|
-
}
|
|
181
|
-
set(cookieName, cookieValue, options = {}) {
|
|
182
|
-
this[LIVE_COOKIE][cookieName] = typeof cookieValue === "string" ? cookieValue : JSON.stringify(cookieValue);
|
|
183
|
-
const resolvedValue = typeof cookieValue === "string" ? cookieValue : encodeURIComponent(JSON.stringify(cookieValue));
|
|
184
|
-
this[RES_COOKIE][cookieName] = createSetCookieValue(cookieName, resolvedValue, options);
|
|
185
|
-
}
|
|
186
|
-
append(cookieName, cookieValue, options = {}) {
|
|
187
|
-
this[LIVE_COOKIE][cookieName] = typeof cookieValue === "string" ? cookieValue : JSON.stringify(cookieValue);
|
|
188
|
-
const resolvedValue = typeof cookieValue === "string" ? cookieValue : encodeURIComponent(JSON.stringify(cookieValue));
|
|
189
|
-
this[RES_COOKIE][++this.appendCounter] = createSetCookieValue(
|
|
190
|
-
cookieName,
|
|
191
|
-
resolvedValue,
|
|
192
|
-
options
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
delete(name, options) {
|
|
196
|
-
this.set(name, "deleted", { ...options, maxAge: 0 });
|
|
197
|
-
this[LIVE_COOKIE][name] = null;
|
|
198
|
-
}
|
|
199
|
-
headers() {
|
|
200
|
-
return Object.values(this[RES_COOKIE]);
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
var mergeHeadersCookies = (headers, cookies) => {
|
|
204
|
-
const cookieHeaders = cookies.headers();
|
|
205
|
-
if (cookieHeaders.length > 0) {
|
|
206
|
-
const newHeaders = new Headers(headers);
|
|
207
|
-
for (const cookie of cookieHeaders) {
|
|
208
|
-
newHeaders.append("Set-Cookie", cookie);
|
|
209
|
-
}
|
|
210
|
-
return newHeaders;
|
|
211
|
-
}
|
|
212
|
-
return headers;
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
// packages/qwik-router/src/middleware/request-handler/redirect-handler.ts
|
|
216
|
-
var AbortMessage = class {
|
|
217
|
-
};
|
|
218
|
-
var RedirectMessage = class extends AbortMessage {
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
// packages/qwik-router/src/middleware/request-handler/rewrite-handler.ts
|
|
222
|
-
var RewriteMessage = class extends AbortMessage {
|
|
223
|
-
constructor(pathname) {
|
|
224
|
-
super();
|
|
225
|
-
this.pathname = pathname;
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
|
|
229
1
|
// packages/qwik-router/src/runtime/src/constants.ts
|
|
230
2
|
var MODULE_CACHE = /* @__PURE__ */ new WeakMap();
|
|
231
3
|
var QACTION_KEY = "qaction";
|
|
@@ -526,7 +298,228 @@ function createCacheControl(cacheControl) {
|
|
|
526
298
|
return controls.join(", ");
|
|
527
299
|
}
|
|
528
300
|
|
|
301
|
+
// packages/qwik-router/src/middleware/request-handler/cookie.ts
|
|
302
|
+
var SAMESITE = {
|
|
303
|
+
lax: "Lax",
|
|
304
|
+
Lax: "Lax",
|
|
305
|
+
None: "None",
|
|
306
|
+
none: "None",
|
|
307
|
+
strict: "Strict",
|
|
308
|
+
Strict: "Strict"
|
|
309
|
+
};
|
|
310
|
+
var UNIT = {
|
|
311
|
+
seconds: 1,
|
|
312
|
+
minutes: 1 * 60,
|
|
313
|
+
hours: 1 * 60 * 60,
|
|
314
|
+
days: 1 * 60 * 60 * 24,
|
|
315
|
+
weeks: 1 * 60 * 60 * 24 * 7
|
|
316
|
+
};
|
|
317
|
+
var createSetCookieValue = (cookieName, cookieValue, options) => {
|
|
318
|
+
const c = [`${cookieName}=${cookieValue}`];
|
|
319
|
+
if (typeof options.domain === "string") {
|
|
320
|
+
c.push(`Domain=${options.domain}`);
|
|
321
|
+
}
|
|
322
|
+
if (typeof options.maxAge === "number") {
|
|
323
|
+
c.push(`Max-Age=${options.maxAge}`);
|
|
324
|
+
} else if (Array.isArray(options.maxAge)) {
|
|
325
|
+
c.push(`Max-Age=${options.maxAge[0] * UNIT[options.maxAge[1]]}`);
|
|
326
|
+
} else if (typeof options.expires === "number" || typeof options.expires == "string") {
|
|
327
|
+
c.push(`Expires=${options.expires}`);
|
|
328
|
+
} else if (options.expires instanceof Date) {
|
|
329
|
+
c.push(`Expires=${options.expires.toUTCString()}`);
|
|
330
|
+
}
|
|
331
|
+
if (options.httpOnly) {
|
|
332
|
+
c.push("HttpOnly");
|
|
333
|
+
}
|
|
334
|
+
if (typeof options.path === "string") {
|
|
335
|
+
c.push(`Path=${options.path}`);
|
|
336
|
+
}
|
|
337
|
+
const sameSite = resolveSameSite(options.sameSite);
|
|
338
|
+
if (sameSite) {
|
|
339
|
+
c.push(`SameSite=${sameSite}`);
|
|
340
|
+
}
|
|
341
|
+
if (options.secure) {
|
|
342
|
+
c.push("Secure");
|
|
343
|
+
}
|
|
344
|
+
return c.join("; ");
|
|
345
|
+
};
|
|
346
|
+
function tryDecodeUriComponent(str) {
|
|
347
|
+
try {
|
|
348
|
+
return decodeURIComponent(str);
|
|
349
|
+
} catch {
|
|
350
|
+
return str;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
var parseCookieString = (cookieString) => {
|
|
354
|
+
const cookie = {};
|
|
355
|
+
if (typeof cookieString === "string" && cookieString !== "") {
|
|
356
|
+
const cookieSegments = cookieString.split(";");
|
|
357
|
+
for (const cookieSegment of cookieSegments) {
|
|
358
|
+
const separatorIndex = cookieSegment.indexOf("=");
|
|
359
|
+
if (separatorIndex !== -1) {
|
|
360
|
+
cookie[tryDecodeUriComponent(cookieSegment.slice(0, separatorIndex).trim())] = tryDecodeUriComponent(cookieSegment.slice(separatorIndex + 1).trim());
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return cookie;
|
|
365
|
+
};
|
|
366
|
+
function resolveSameSite(sameSite) {
|
|
367
|
+
if (sameSite === true) {
|
|
368
|
+
return "Strict";
|
|
369
|
+
}
|
|
370
|
+
if (sameSite === false) {
|
|
371
|
+
return "None";
|
|
372
|
+
}
|
|
373
|
+
if (sameSite) {
|
|
374
|
+
return SAMESITE[sameSite];
|
|
375
|
+
}
|
|
376
|
+
return void 0;
|
|
377
|
+
}
|
|
378
|
+
var REQ_COOKIE = Symbol("request-cookies");
|
|
379
|
+
var RES_COOKIE = Symbol("response-cookies");
|
|
380
|
+
var LIVE_COOKIE = Symbol("live-cookies");
|
|
381
|
+
var Cookie = class {
|
|
382
|
+
[REQ_COOKIE];
|
|
383
|
+
[RES_COOKIE] = {};
|
|
384
|
+
[LIVE_COOKIE] = {};
|
|
385
|
+
appendCounter = 0;
|
|
386
|
+
constructor(cookieString) {
|
|
387
|
+
this[REQ_COOKIE] = parseCookieString(cookieString);
|
|
388
|
+
this[LIVE_COOKIE] = { ...this[REQ_COOKIE] };
|
|
389
|
+
}
|
|
390
|
+
get(cookieName, live = true) {
|
|
391
|
+
const value = this[live ? LIVE_COOKIE : REQ_COOKIE][cookieName];
|
|
392
|
+
if (!value) {
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
return {
|
|
396
|
+
value,
|
|
397
|
+
json() {
|
|
398
|
+
return JSON.parse(value);
|
|
399
|
+
},
|
|
400
|
+
number() {
|
|
401
|
+
return Number(value);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
getAll(live = true) {
|
|
406
|
+
return Object.keys(this[live ? LIVE_COOKIE : REQ_COOKIE]).reduce(
|
|
407
|
+
(cookies, cookieName) => {
|
|
408
|
+
cookies[cookieName] = this.get(cookieName);
|
|
409
|
+
return cookies;
|
|
410
|
+
},
|
|
411
|
+
{}
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
has(cookieName, live = true) {
|
|
415
|
+
return !!this[live ? LIVE_COOKIE : REQ_COOKIE][cookieName];
|
|
416
|
+
}
|
|
417
|
+
set(cookieName, cookieValue, options = {}) {
|
|
418
|
+
this[LIVE_COOKIE][cookieName] = typeof cookieValue === "string" ? cookieValue : JSON.stringify(cookieValue);
|
|
419
|
+
const resolvedValue = typeof cookieValue === "string" ? cookieValue : encodeURIComponent(JSON.stringify(cookieValue));
|
|
420
|
+
this[RES_COOKIE][cookieName] = createSetCookieValue(cookieName, resolvedValue, options);
|
|
421
|
+
}
|
|
422
|
+
append(cookieName, cookieValue, options = {}) {
|
|
423
|
+
this[LIVE_COOKIE][cookieName] = typeof cookieValue === "string" ? cookieValue : JSON.stringify(cookieValue);
|
|
424
|
+
const resolvedValue = typeof cookieValue === "string" ? cookieValue : encodeURIComponent(JSON.stringify(cookieValue));
|
|
425
|
+
this[RES_COOKIE][++this.appendCounter] = createSetCookieValue(
|
|
426
|
+
cookieName,
|
|
427
|
+
resolvedValue,
|
|
428
|
+
options
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
delete(name, options) {
|
|
432
|
+
this.set(name, "deleted", { ...options, maxAge: 0 });
|
|
433
|
+
this[LIVE_COOKIE][name] = null;
|
|
434
|
+
}
|
|
435
|
+
headers() {
|
|
436
|
+
return Object.values(this[RES_COOKIE]);
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
var mergeHeadersCookies = (headers, cookies) => {
|
|
440
|
+
const cookieHeaders = cookies.headers();
|
|
441
|
+
if (cookieHeaders.length > 0) {
|
|
442
|
+
const newHeaders = new Headers(headers);
|
|
443
|
+
for (const cookie of cookieHeaders) {
|
|
444
|
+
newHeaders.append("Set-Cookie", cookie);
|
|
445
|
+
}
|
|
446
|
+
return newHeaders;
|
|
447
|
+
}
|
|
448
|
+
return headers;
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
// packages/qwik-router/src/middleware/request-handler/request-event.ts
|
|
452
|
+
import {
|
|
453
|
+
AbortMessage as AbortMessage2,
|
|
454
|
+
RedirectMessage as RedirectMessage2,
|
|
455
|
+
ServerError as ServerError2,
|
|
456
|
+
RewriteMessage as RewriteMessage2
|
|
457
|
+
} from "@qwik.dev/router/middleware/request-handler";
|
|
458
|
+
|
|
459
|
+
// packages/qwik-router/src/middleware/request-handler/error-handler.ts
|
|
460
|
+
function getErrorHtml(status, e) {
|
|
461
|
+
let message = "Server Error";
|
|
462
|
+
if (e != null) {
|
|
463
|
+
if (typeof e.message === "string") {
|
|
464
|
+
message = e.message;
|
|
465
|
+
} else {
|
|
466
|
+
message = String(e);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
return `<html>` + minimalHtmlResponse(status, message) + `</html>`;
|
|
470
|
+
}
|
|
471
|
+
function minimalHtmlResponse(status, message) {
|
|
472
|
+
if (typeof status !== "number") {
|
|
473
|
+
status = 500;
|
|
474
|
+
}
|
|
475
|
+
if (typeof message === "string") {
|
|
476
|
+
message = escapeHtml(message);
|
|
477
|
+
} else {
|
|
478
|
+
message = "";
|
|
479
|
+
}
|
|
480
|
+
const width = typeof message === "string" ? "600px" : "300px";
|
|
481
|
+
const color = status >= 500 ? COLOR_500 : COLOR_400;
|
|
482
|
+
return `
|
|
483
|
+
<head>
|
|
484
|
+
<meta charset="utf-8">
|
|
485
|
+
<meta http-equiv="Status" content="${status}">
|
|
486
|
+
<title>${status} ${message}</title>
|
|
487
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
488
|
+
<style>
|
|
489
|
+
body { color: ${color}; background-color: #fafafa; padding: 30px; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif; }
|
|
490
|
+
p { max-width: ${width}; margin: 60px auto 30px auto; background: white; border-radius: 4px; box-shadow: 0px 0px 50px -20px ${color}; overflow: hidden; }
|
|
491
|
+
strong { display: inline-block; padding: 15px; background: ${color}; color: white; }
|
|
492
|
+
span { display: inline-block; padding: 15px; }
|
|
493
|
+
</style>
|
|
494
|
+
</head>
|
|
495
|
+
<body><p><strong>${status}</strong> <span>${message}</span></p></body>
|
|
496
|
+
`;
|
|
497
|
+
}
|
|
498
|
+
var ESCAPE_HTML = /[&<>]/g;
|
|
499
|
+
var escapeHtml = (s) => {
|
|
500
|
+
return s.replace(ESCAPE_HTML, (c) => {
|
|
501
|
+
switch (c) {
|
|
502
|
+
case "&":
|
|
503
|
+
return "&";
|
|
504
|
+
case "<":
|
|
505
|
+
return "<";
|
|
506
|
+
case ">":
|
|
507
|
+
return ">";
|
|
508
|
+
default:
|
|
509
|
+
return "";
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
};
|
|
513
|
+
var COLOR_400 = "#006ce9";
|
|
514
|
+
var COLOR_500 = "#713fc2";
|
|
515
|
+
|
|
529
516
|
// packages/qwik-router/src/middleware/request-handler/user-response.ts
|
|
517
|
+
import {
|
|
518
|
+
AbortMessage,
|
|
519
|
+
RedirectMessage,
|
|
520
|
+
ServerError,
|
|
521
|
+
RewriteMessage
|
|
522
|
+
} from "@qwik.dev/router/middleware/request-handler";
|
|
530
523
|
var asyncStore;
|
|
531
524
|
import("node:async_hooks").then((module) => {
|
|
532
525
|
const AsyncLocalStorage = module.AsyncLocalStorage;
|
|
@@ -538,14 +531,13 @@ import("node:async_hooks").then((module) => {
|
|
|
538
531
|
err
|
|
539
532
|
);
|
|
540
533
|
});
|
|
541
|
-
function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, rebuildRouteInfo,
|
|
534
|
+
function runQwikRouter(serverRequestEv, loadedRoute, requestHandlers, rebuildRouteInfo, basePathname = "/", qwikSerializer) {
|
|
542
535
|
let resolve;
|
|
543
536
|
const responsePromise = new Promise((r) => resolve = r);
|
|
544
537
|
const requestEv = createRequestEvent(
|
|
545
538
|
serverRequestEv,
|
|
546
539
|
loadedRoute,
|
|
547
540
|
requestHandlers,
|
|
548
|
-
trailingSlash,
|
|
549
541
|
basePathname,
|
|
550
542
|
qwikSerializer,
|
|
551
543
|
resolve
|
|
@@ -599,7 +591,7 @@ async function runNext(requestEv, rebuildRouteInfo, resolve) {
|
|
|
599
591
|
const stream = requestEv.getWritableStream();
|
|
600
592
|
if (!stream.locked) {
|
|
601
593
|
const writer = stream.getWriter();
|
|
602
|
-
await writer.write(encoder.encode(
|
|
594
|
+
await writer.write(encoder.encode(getErrorHtml(500, "Internal Server Error")));
|
|
603
595
|
await writer.close();
|
|
604
596
|
}
|
|
605
597
|
} catch {
|
|
@@ -619,9 +611,9 @@ async function runNext(requestEv, rebuildRouteInfo, resolve) {
|
|
|
619
611
|
}
|
|
620
612
|
}
|
|
621
613
|
}
|
|
622
|
-
function getRouteMatchPathname(pathname
|
|
614
|
+
function getRouteMatchPathname(pathname) {
|
|
623
615
|
if (pathname.endsWith(QDATA_JSON)) {
|
|
624
|
-
const trimEnd = pathname.length - QDATA_JSON_LEN + (
|
|
616
|
+
const trimEnd = pathname.length - QDATA_JSON_LEN + (globalThis.__NO_TRAILING_SLASH__ ? 0 : 1);
|
|
625
617
|
pathname = pathname.slice(0, trimEnd);
|
|
626
618
|
if (pathname === "") {
|
|
627
619
|
pathname = "/";
|
|
@@ -641,7 +633,6 @@ var RequestEvQwikSerializer = Symbol("RequestEvQwikSerializer");
|
|
|
641
633
|
var RequestEvLoaderSerializationStrategyMap = Symbol(
|
|
642
634
|
"RequestEvLoaderSerializationStrategyMap"
|
|
643
635
|
);
|
|
644
|
-
var RequestEvTrailingSlash = Symbol("RequestEvTrailingSlash");
|
|
645
636
|
var RequestRouteName = "@routeName";
|
|
646
637
|
var RequestEvSharedActionId = "@actionId";
|
|
647
638
|
var RequestEvSharedActionFormData = "@actionFormData";
|
|
@@ -649,7 +640,7 @@ var RequestEvSharedNonce = "@nonce";
|
|
|
649
640
|
var RequestEvIsRewrite = "@rewrite";
|
|
650
641
|
var RequestEvShareServerTiming = "@serverTiming";
|
|
651
642
|
var RequestEvShareQData = "qData";
|
|
652
|
-
function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers,
|
|
643
|
+
function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, basePathname, qwikSerializer, resolved) {
|
|
653
644
|
const { request, platform, env } = serverRequestEv;
|
|
654
645
|
const sharedMap = /* @__PURE__ */ new Map();
|
|
655
646
|
const cookie = new Cookie(request.headers.get("cookie"));
|
|
@@ -657,7 +648,7 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, trail
|
|
|
657
648
|
const url = new URL(request.url);
|
|
658
649
|
if (url.pathname.endsWith(QDATA_JSON)) {
|
|
659
650
|
url.pathname = url.pathname.slice(0, -QDATA_JSON_LEN);
|
|
660
|
-
if (
|
|
651
|
+
if (!globalThis.__NO_TRAILING_SLASH__ && !url.pathname.endsWith("/")) {
|
|
661
652
|
url.pathname += "/";
|
|
662
653
|
}
|
|
663
654
|
sharedMap.set(IsQData, true);
|
|
@@ -727,14 +718,13 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, trail
|
|
|
727
718
|
};
|
|
728
719
|
const exit = () => {
|
|
729
720
|
routeModuleIndex = ABORT_INDEX;
|
|
730
|
-
return new
|
|
721
|
+
return new AbortMessage2();
|
|
731
722
|
};
|
|
732
723
|
const loaders = {};
|
|
733
724
|
const requestEv = {
|
|
734
725
|
[RequestEvLoaders]: loaders,
|
|
735
726
|
[RequestEvLoaderSerializationStrategyMap]: /* @__PURE__ */ new Map(),
|
|
736
727
|
[RequestEvMode]: serverRequestEv.mode,
|
|
737
|
-
[RequestEvTrailingSlash]: trailingSlash,
|
|
738
728
|
get [RequestEvRoute]() {
|
|
739
729
|
return loadedRoute;
|
|
740
730
|
},
|
|
@@ -806,7 +796,7 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, trail
|
|
|
806
796
|
},
|
|
807
797
|
error: (statusCode, message) => {
|
|
808
798
|
status = statusCode;
|
|
809
|
-
return new
|
|
799
|
+
return new ServerError2(statusCode, message);
|
|
810
800
|
},
|
|
811
801
|
redirect: (statusCode, url2) => {
|
|
812
802
|
check();
|
|
@@ -822,7 +812,7 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, trail
|
|
|
822
812
|
headers.set("Cache-Control", "no-store");
|
|
823
813
|
}
|
|
824
814
|
exit();
|
|
825
|
-
return new
|
|
815
|
+
return new RedirectMessage2();
|
|
826
816
|
},
|
|
827
817
|
rewrite: (pathname) => {
|
|
828
818
|
check();
|
|
@@ -830,7 +820,7 @@ function createRequestEvent(serverRequestEv, loadedRoute, requestHandlers, trail
|
|
|
830
820
|
throw new Error("Rewrite does not support absolute urls");
|
|
831
821
|
}
|
|
832
822
|
sharedMap.set(RequestEvIsRewrite, true);
|
|
833
|
-
return new
|
|
823
|
+
return new RewriteMessage2(pathname.replace(/\/+/g, "/"));
|
|
834
824
|
},
|
|
835
825
|
defer: (returnData) => {
|
|
836
826
|
return typeof returnData === "function" ? returnData : () => returnData;
|
|
@@ -895,9 +885,6 @@ function getRequestLoaders(requestEv) {
|
|
|
895
885
|
function getRequestLoaderSerializationStrategyMap(requestEv) {
|
|
896
886
|
return requestEv[RequestEvLoaderSerializationStrategyMap];
|
|
897
887
|
}
|
|
898
|
-
function getRequestTrailingSlash(requestEv) {
|
|
899
|
-
return requestEv[RequestEvTrailingSlash];
|
|
900
|
-
}
|
|
901
888
|
function getRequestRoute(requestEv) {
|
|
902
889
|
return requestEv[RequestEvRoute];
|
|
903
890
|
}
|
|
@@ -994,6 +981,7 @@ function getQwikRouterServerData(requestEv) {
|
|
|
994
981
|
}
|
|
995
982
|
|
|
996
983
|
// packages/qwik-router/src/middleware/request-handler/resolve-request-handlers.ts
|
|
984
|
+
import { RedirectMessage as RedirectMessage3, ServerError as ServerError3 } from "@qwik.dev/router/middleware/request-handler";
|
|
997
985
|
var resolveRequestHandlers = (serverPlugins, route, method, checkOrigin, renderHandler) => {
|
|
998
986
|
const routeLoaders = [];
|
|
999
987
|
const routeActions = [];
|
|
@@ -1013,6 +1001,9 @@ var resolveRequestHandlers = (serverPlugins, route, method, checkOrigin, renderH
|
|
|
1013
1001
|
const routeName = route[0 /* RouteName */];
|
|
1014
1002
|
if (checkOrigin && (method === "POST" || method === "PUT" || method === "PATCH" || method === "DELETE")) {
|
|
1015
1003
|
requestHandlers.unshift(csrfCheckMiddleware);
|
|
1004
|
+
if (checkOrigin === "lax-proto") {
|
|
1005
|
+
requestHandlers.push(csrfLaxProtoCheckMiddleware);
|
|
1006
|
+
}
|
|
1016
1007
|
}
|
|
1017
1008
|
if (isPageRoute) {
|
|
1018
1009
|
if (method === "POST" || method === "GET") {
|
|
@@ -1266,7 +1257,7 @@ async function pureServerFunction(ev) {
|
|
|
1266
1257
|
result = await qrl.apply(ev, args);
|
|
1267
1258
|
}
|
|
1268
1259
|
} catch (err) {
|
|
1269
|
-
if (err instanceof
|
|
1260
|
+
if (err instanceof ServerError3) {
|
|
1270
1261
|
throw ev.error(err.status, err.data);
|
|
1271
1262
|
}
|
|
1272
1263
|
throw ev.error(500, "Invalid request");
|
|
@@ -1300,12 +1291,11 @@ async function pureServerFunction(ev) {
|
|
|
1300
1291
|
}
|
|
1301
1292
|
}
|
|
1302
1293
|
function fixTrailingSlash(ev) {
|
|
1303
|
-
const trailingSlash = getRequestTrailingSlash(ev);
|
|
1304
1294
|
const { basePathname, originalUrl, sharedMap } = ev;
|
|
1305
1295
|
const { pathname, search } = originalUrl;
|
|
1306
1296
|
const isQData = sharedMap.has(IsQData);
|
|
1307
1297
|
if (!isQData && pathname !== basePathname && !pathname.endsWith(".html")) {
|
|
1308
|
-
if (
|
|
1298
|
+
if (!globalThis.__NO_TRAILING_SLASH__) {
|
|
1309
1299
|
if (!pathname.endsWith("/")) {
|
|
1310
1300
|
throw ev.redirect(301 /* MovedPermanently */, pathname + "/" + search);
|
|
1311
1301
|
}
|
|
@@ -1336,12 +1326,12 @@ function isLastModulePageRoute(routeModules) {
|
|
|
1336
1326
|
const lastRouteModule = routeModules[routeModules.length - 1];
|
|
1337
1327
|
return lastRouteModule && typeof lastRouteModule.default === "function";
|
|
1338
1328
|
}
|
|
1339
|
-
function getPathname(url
|
|
1329
|
+
function getPathname(url) {
|
|
1340
1330
|
url = new URL(url);
|
|
1341
1331
|
if (url.pathname.endsWith(QDATA_JSON)) {
|
|
1342
1332
|
url.pathname = url.pathname.slice(0, -QDATA_JSON.length);
|
|
1343
1333
|
}
|
|
1344
|
-
if (
|
|
1334
|
+
if (!globalThis.__NO_TRAILING_SLASH__) {
|
|
1345
1335
|
if (!url.pathname.endsWith("/")) {
|
|
1346
1336
|
url.pathname += "/";
|
|
1347
1337
|
}
|
|
@@ -1354,7 +1344,13 @@ function getPathname(url, trailingSlash) {
|
|
|
1354
1344
|
return `${url.pathname}${search ? `?${search}` : ""}${url.hash}`;
|
|
1355
1345
|
}
|
|
1356
1346
|
var encoder = /* @__PURE__ */ new TextEncoder();
|
|
1347
|
+
function csrfLaxProtoCheckMiddleware(requestEv) {
|
|
1348
|
+
checkCSRF(requestEv, "lax-proto");
|
|
1349
|
+
}
|
|
1357
1350
|
function csrfCheckMiddleware(requestEv) {
|
|
1351
|
+
checkCSRF(requestEv);
|
|
1352
|
+
}
|
|
1353
|
+
function checkCSRF(requestEv, laxProto) {
|
|
1358
1354
|
const isForm = isContentType(
|
|
1359
1355
|
requestEv.request.headers,
|
|
1360
1356
|
"application/x-www-form-urlencoded",
|
|
@@ -1364,7 +1360,10 @@ function csrfCheckMiddleware(requestEv) {
|
|
|
1364
1360
|
if (isForm) {
|
|
1365
1361
|
const inputOrigin = requestEv.request.headers.get("origin");
|
|
1366
1362
|
const origin = requestEv.url.origin;
|
|
1367
|
-
|
|
1363
|
+
let forbidden = inputOrigin !== origin;
|
|
1364
|
+
if (forbidden && laxProto && origin.startsWith("https://") && (inputOrigin == null ? void 0 : inputOrigin.slice(4)) === origin.slice(5)) {
|
|
1365
|
+
forbidden = false;
|
|
1366
|
+
}
|
|
1368
1367
|
if (forbidden) {
|
|
1369
1368
|
throw requestEv.error(
|
|
1370
1369
|
403,
|
|
@@ -1389,7 +1388,6 @@ function renderQwikMiddleware(render) {
|
|
|
1389
1388
|
if (!responseHeaders.has("Content-Type")) {
|
|
1390
1389
|
responseHeaders.set("Content-Type", "text/html; charset=utf-8");
|
|
1391
1390
|
}
|
|
1392
|
-
const trailingSlash = getRequestTrailingSlash(requestEv);
|
|
1393
1391
|
const { readable, writable } = new TextEncoderStream();
|
|
1394
1392
|
const writableStream = requestEv.getWritableStream();
|
|
1395
1393
|
const pipe = readable.pipeTo(writableStream, { preventClose: true });
|
|
@@ -1411,7 +1409,7 @@ function renderQwikMiddleware(render) {
|
|
|
1411
1409
|
loaders: getRequestLoaders(requestEv),
|
|
1412
1410
|
action: requestEv.sharedMap.get(RequestEvSharedActionId),
|
|
1413
1411
|
status: status !== 200 ? status : 200,
|
|
1414
|
-
href: getPathname(requestEv.url
|
|
1412
|
+
href: getPathname(requestEv.url)
|
|
1415
1413
|
};
|
|
1416
1414
|
if (typeof result.html === "string") {
|
|
1417
1415
|
await stream.write(result.html);
|
|
@@ -1433,7 +1431,7 @@ async function handleRedirect(requestEv) {
|
|
|
1433
1431
|
try {
|
|
1434
1432
|
await requestEv.next();
|
|
1435
1433
|
} catch (err) {
|
|
1436
|
-
if (!(err instanceof
|
|
1434
|
+
if (!(err instanceof RedirectMessage3)) {
|
|
1437
1435
|
throw err;
|
|
1438
1436
|
}
|
|
1439
1437
|
}
|
|
@@ -1466,7 +1464,6 @@ async function renderQData(requestEv) {
|
|
|
1466
1464
|
}
|
|
1467
1465
|
const status = requestEv.status();
|
|
1468
1466
|
const redirectLocation = requestEv.headers.get("Location");
|
|
1469
|
-
const trailingSlash = getRequestTrailingSlash(requestEv);
|
|
1470
1467
|
const requestHeaders = {};
|
|
1471
1468
|
requestEv.request.headers.forEach((value, key) => requestHeaders[key] = value);
|
|
1472
1469
|
requestEv.headers.set("Content-Type", "application/json; charset=utf-8");
|
|
@@ -1485,12 +1482,12 @@ async function renderQData(requestEv) {
|
|
|
1485
1482
|
// send minimal data to the client
|
|
1486
1483
|
loaders,
|
|
1487
1484
|
status: status !== 200 ? status : 200,
|
|
1488
|
-
href: getPathname(requestEv.url
|
|
1485
|
+
href: getPathname(requestEv.url)
|
|
1489
1486
|
} : {
|
|
1490
1487
|
loaders,
|
|
1491
1488
|
action: requestEv.sharedMap.get(RequestEvSharedActionId),
|
|
1492
1489
|
status: status !== 200 ? status : 200,
|
|
1493
|
-
href: getPathname(requestEv.url
|
|
1490
|
+
href: getPathname(requestEv.url),
|
|
1494
1491
|
redirect: redirectLocation ?? void 0,
|
|
1495
1492
|
isRewrite: requestEv.sharedMap.get(RequestEvIsRewrite)
|
|
1496
1493
|
};
|
|
@@ -1534,13 +1531,21 @@ function isContentType(headers, ...types) {
|
|
|
1534
1531
|
}
|
|
1535
1532
|
|
|
1536
1533
|
// packages/qwik-router/src/middleware/request-handler/request-handler.ts
|
|
1534
|
+
var qwikRouterConfigActual;
|
|
1537
1535
|
async function requestHandler(serverRequestEv, opts, qwikSerializer) {
|
|
1538
|
-
const { render,
|
|
1536
|
+
const { render, checkOrigin } = opts;
|
|
1537
|
+
let { qwikRouterConfig } = opts;
|
|
1538
|
+
if (!qwikRouterConfig) {
|
|
1539
|
+
if (!qwikRouterConfigActual) {
|
|
1540
|
+
qwikRouterConfigActual = await import("@qwik-router-config");
|
|
1541
|
+
}
|
|
1542
|
+
qwikRouterConfig = qwikRouterConfigActual;
|
|
1543
|
+
}
|
|
1539
1544
|
if (!qwikRouterConfig) {
|
|
1540
1545
|
throw new Error("qwikRouterConfig is required.");
|
|
1541
1546
|
}
|
|
1542
1547
|
const pathname = serverRequestEv.url.pathname;
|
|
1543
|
-
const matchPathname = getRouteMatchPathname(pathname
|
|
1548
|
+
const matchPathname = getRouteMatchPathname(pathname);
|
|
1544
1549
|
const routeAndHandlers = await loadRequestHandlers(
|
|
1545
1550
|
qwikRouterConfig,
|
|
1546
1551
|
matchPathname,
|
|
@@ -1551,7 +1556,7 @@ async function requestHandler(serverRequestEv, opts, qwikSerializer) {
|
|
|
1551
1556
|
if (routeAndHandlers) {
|
|
1552
1557
|
const [route, requestHandlers] = routeAndHandlers;
|
|
1553
1558
|
const rebuildRouteInfo = async (url) => {
|
|
1554
|
-
const matchPathname2 = getRouteMatchPathname(url.pathname
|
|
1559
|
+
const matchPathname2 = getRouteMatchPathname(url.pathname);
|
|
1555
1560
|
const routeAndHandlers2 = await loadRequestHandlers(
|
|
1556
1561
|
qwikRouterConfig,
|
|
1557
1562
|
matchPathname2,
|
|
@@ -1571,7 +1576,6 @@ async function requestHandler(serverRequestEv, opts, qwikSerializer) {
|
|
|
1571
1576
|
route,
|
|
1572
1577
|
requestHandlers,
|
|
1573
1578
|
rebuildRouteInfo,
|
|
1574
|
-
qwikRouterConfig.trailingSlash,
|
|
1575
1579
|
qwikRouterConfig.basePathname,
|
|
1576
1580
|
qwikSerializer
|
|
1577
1581
|
);
|
|
@@ -1594,6 +1598,71 @@ async function loadRequestHandlers(qwikRouterConfig, pathname, method, checkOrig
|
|
|
1594
1598
|
return null;
|
|
1595
1599
|
}
|
|
1596
1600
|
|
|
1601
|
+
// packages/qwik-router/src/middleware/request-handler/not-found-paths.ts
|
|
1602
|
+
var notFounds = [
|
|
1603
|
+
// Will be replaced in post-build with the 404s generated by SSG
|
|
1604
|
+
"__QWIK_ROUTER_NOT_FOUND_ARRAY__"
|
|
1605
|
+
];
|
|
1606
|
+
function getNotFound(prefix) {
|
|
1607
|
+
for (const [path, html] of notFounds) {
|
|
1608
|
+
if (prefix.startsWith(path)) {
|
|
1609
|
+
return html;
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
return minimalHtmlResponse(404, "Resource Not Found");
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
// packages/qwik-router/src/middleware/request-handler/static-paths.ts
|
|
1616
|
+
var staticPaths = /* @__PURE__ */ new Set(["__QWIK_ROUTER_STATIC_PATHS_ARRAY__"]);
|
|
1617
|
+
function isStaticPath(method, url) {
|
|
1618
|
+
if (method.toUpperCase() !== "GET") {
|
|
1619
|
+
return false;
|
|
1620
|
+
}
|
|
1621
|
+
const p = url.pathname;
|
|
1622
|
+
if (p.startsWith("/" + (globalThis.__QWIK_BUILD_DIR__ || "build") + "/")) {
|
|
1623
|
+
return true;
|
|
1624
|
+
}
|
|
1625
|
+
if (p.startsWith("/" + (globalThis.__QWIK_ASSETS_DIR__ || "assets") + "/")) {
|
|
1626
|
+
return true;
|
|
1627
|
+
}
|
|
1628
|
+
if (staticPaths.has(p)) {
|
|
1629
|
+
return true;
|
|
1630
|
+
}
|
|
1631
|
+
if (p.endsWith("/q-data.json")) {
|
|
1632
|
+
const pWithoutQdata = p.replace(/\/q-data.json$/, "");
|
|
1633
|
+
if (staticPaths.has(pWithoutQdata + "/")) {
|
|
1634
|
+
return true;
|
|
1635
|
+
}
|
|
1636
|
+
if (staticPaths.has(pWithoutQdata)) {
|
|
1637
|
+
return true;
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
return false;
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
// packages/qwik-router/src/middleware/request-handler/server-error.ts
|
|
1644
|
+
var ServerError4 = class extends Error {
|
|
1645
|
+
constructor(status, data) {
|
|
1646
|
+
super(typeof data === "string" ? data : void 0);
|
|
1647
|
+
this.status = status;
|
|
1648
|
+
this.data = data;
|
|
1649
|
+
}
|
|
1650
|
+
};
|
|
1651
|
+
|
|
1652
|
+
// packages/qwik-router/src/middleware/request-handler/redirect-handler.ts
|
|
1653
|
+
var AbortMessage3 = class {
|
|
1654
|
+
};
|
|
1655
|
+
var RedirectMessage4 = class extends AbortMessage3 {
|
|
1656
|
+
};
|
|
1657
|
+
|
|
1658
|
+
// packages/qwik-router/src/middleware/request-handler/rewrite-handler.ts
|
|
1659
|
+
var RewriteMessage3 = class extends AbortMessage3 {
|
|
1660
|
+
constructor(pathname) {
|
|
1661
|
+
super();
|
|
1662
|
+
this.pathname = pathname;
|
|
1663
|
+
}
|
|
1664
|
+
};
|
|
1665
|
+
|
|
1597
1666
|
// packages/qwik-router/src/middleware/request-handler/polyfill.ts
|
|
1598
1667
|
var _TextEncoderStream_polyfill = class {
|
|
1599
1668
|
#pendingHighSurrogate = null;
|
|
@@ -1648,13 +1717,15 @@ var _TextEncoderStream_polyfill = class {
|
|
|
1648
1717
|
}
|
|
1649
1718
|
};
|
|
1650
1719
|
export {
|
|
1651
|
-
AbortMessage,
|
|
1652
|
-
RedirectMessage,
|
|
1720
|
+
AbortMessage3 as AbortMessage,
|
|
1721
|
+
RedirectMessage4 as RedirectMessage,
|
|
1653
1722
|
RequestEvShareQData,
|
|
1654
|
-
RewriteMessage,
|
|
1655
|
-
ServerError,
|
|
1723
|
+
RewriteMessage3 as RewriteMessage,
|
|
1724
|
+
ServerError4 as ServerError,
|
|
1656
1725
|
_TextEncoderStream_polyfill,
|
|
1657
1726
|
getErrorHtml,
|
|
1727
|
+
getNotFound,
|
|
1728
|
+
isStaticPath,
|
|
1658
1729
|
mergeHeadersCookies,
|
|
1659
1730
|
requestHandler
|
|
1660
1731
|
};
|