astro 7.1.0 → 7.1.2
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/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/content/mutable-data-store.js +2 -2
- package/dist/content/runtime.js +2 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/cookies/cookies.js +19 -19
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/fetch/fetch-state.js +37 -26
- package/dist/core/i18n/domain.d.ts +1 -1
- package/dist/core/i18n/domain.js +4 -5
- package/dist/core/messages/runtime.js +1 -1
- package/dist/prefetch/index.js +2 -1
- package/package.json +5 -5
|
@@ -196,7 +196,7 @@ ${contentConfig.error.message}`
|
|
|
196
196
|
logger.info("Content config changed");
|
|
197
197
|
shouldClear = true;
|
|
198
198
|
}
|
|
199
|
-
if (previousAstroVersion && previousAstroVersion !== "7.1.
|
|
199
|
+
if (previousAstroVersion && previousAstroVersion !== "7.1.2") {
|
|
200
200
|
logger.info("Astro version changed");
|
|
201
201
|
shouldClear = true;
|
|
202
202
|
}
|
|
@@ -204,8 +204,8 @@ ${contentConfig.error.message}`
|
|
|
204
204
|
logger.info("Clearing content store");
|
|
205
205
|
this.#store.clearAll();
|
|
206
206
|
}
|
|
207
|
-
if ("7.1.
|
|
208
|
-
this.#store.metaStore().set("astro-version", "7.1.
|
|
207
|
+
if ("7.1.2") {
|
|
208
|
+
this.#store.metaStore().set("astro-version", "7.1.2");
|
|
209
209
|
}
|
|
210
210
|
if (currentConfigDigest) {
|
|
211
211
|
this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, promises as fs } from "node:fs";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import * as devalue from "devalue";
|
|
4
|
-
import {
|
|
4
|
+
import { forEach } from "neotraverse";
|
|
5
5
|
import { imageSrcToImportId, importIdToSymbolName } from "../assets/utils/resolveImports.js";
|
|
6
6
|
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
7
7
|
import { DATA_STORE_MANIFEST_FILE, IMAGE_IMPORT_PREFIX } from "./consts.js";
|
|
@@ -276,7 +276,7 @@ ${lines.join(",\n")}]);
|
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
const foundAssets = new Set(assetImports);
|
|
279
|
-
|
|
279
|
+
forEach(data, (_, val) => {
|
|
280
280
|
if (typeof val === "string" && val.startsWith(IMAGE_IMPORT_PREFIX)) {
|
|
281
281
|
const src = val.replace(IMAGE_IMPORT_PREFIX, "");
|
|
282
282
|
foundAssets.add(src);
|
package/dist/content/runtime.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { escape } from "html-escaper";
|
|
2
|
-
import {
|
|
2
|
+
import { forEach } from "neotraverse";
|
|
3
3
|
import * as z from "zod/v4";
|
|
4
4
|
import { createSvgComponent } from "../assets/runtime.js";
|
|
5
5
|
import { imageSrcToImportId } from "../assets/utils/resolveImports.js";
|
|
@@ -358,7 +358,7 @@ async function updateImageReferencesInBody(html, fileName) {
|
|
|
358
358
|
}
|
|
359
359
|
function updateImageReferencesInData(data, fileName, imageAssetMap) {
|
|
360
360
|
const copy = structuredClone(data);
|
|
361
|
-
|
|
361
|
+
forEach(copy, function(ctx, val) {
|
|
362
362
|
if (typeof val === "string" && val.startsWith(IMAGE_IMPORT_PREFIX)) {
|
|
363
363
|
const src = val.replace(IMAGE_IMPORT_PREFIX, "");
|
|
364
364
|
const id = imageSrcToImportId(src, fileName);
|
package/dist/core/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseCookie, stringifySetCookie } from "cookie";
|
|
2
2
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
3
3
|
const DELETED_EXPIRATION = /* @__PURE__ */ new Date(0);
|
|
4
4
|
const DELETED_VALUE = "deleted";
|
|
@@ -42,20 +42,16 @@ class AstroCookies {
|
|
|
42
42
|
* @param options Options related to this deletion, such as the path of the cookie.
|
|
43
43
|
*/
|
|
44
44
|
delete(key, options) {
|
|
45
|
-
const {
|
|
46
|
-
// @ts-expect-error
|
|
47
|
-
maxAge: _ignoredMaxAge,
|
|
48
|
-
// @ts-expect-error
|
|
49
|
-
expires: _ignoredExpires,
|
|
50
|
-
...sanitizedOptions
|
|
51
|
-
} = options || {};
|
|
52
|
-
const serializeOptions = {
|
|
53
|
-
expires: DELETED_EXPIRATION,
|
|
54
|
-
...sanitizedOptions
|
|
55
|
-
};
|
|
56
45
|
this.#ensureOutgoingMap().set(key, [
|
|
57
46
|
DELETED_VALUE,
|
|
58
|
-
|
|
47
|
+
stringifySetCookie({
|
|
48
|
+
...options,
|
|
49
|
+
name: key,
|
|
50
|
+
value: DELETED_VALUE,
|
|
51
|
+
expires: DELETED_EXPIRATION,
|
|
52
|
+
// Unset `expires` to to ensure that `expires` takes precedence.
|
|
53
|
+
maxAge: void 0
|
|
54
|
+
}),
|
|
59
55
|
false
|
|
60
56
|
]);
|
|
61
57
|
}
|
|
@@ -133,13 +129,17 @@ class AstroCookies {
|
|
|
133
129
|
serializedValue = toStringValue;
|
|
134
130
|
}
|
|
135
131
|
}
|
|
136
|
-
const
|
|
137
|
-
if (options) {
|
|
138
|
-
Object.assign(serializeOptions, options);
|
|
139
|
-
}
|
|
132
|
+
const { encode, ...attributes } = options ?? {};
|
|
140
133
|
this.#ensureOutgoingMap().set(key, [
|
|
141
134
|
serializedValue,
|
|
142
|
-
|
|
135
|
+
stringifySetCookie(
|
|
136
|
+
{
|
|
137
|
+
...attributes,
|
|
138
|
+
name: key,
|
|
139
|
+
value: serializedValue
|
|
140
|
+
},
|
|
141
|
+
{ encode }
|
|
142
|
+
),
|
|
143
143
|
true
|
|
144
144
|
]);
|
|
145
145
|
if (this.#request[responseSentSymbol]) {
|
|
@@ -207,7 +207,7 @@ class AstroCookies {
|
|
|
207
207
|
if (!raw) {
|
|
208
208
|
return;
|
|
209
209
|
}
|
|
210
|
-
this.#requestValues =
|
|
210
|
+
this.#requestValues = parseCookie(raw, { decode: identity });
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
export {
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -26,7 +26,7 @@ async function dev(inlineConfig) {
|
|
|
26
26
|
await telemetry.record([]);
|
|
27
27
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
28
28
|
const logger = restart.container.logger;
|
|
29
|
-
const currentVersion = "7.1.
|
|
29
|
+
const currentVersion = "7.1.2";
|
|
30
30
|
const isPrerelease = currentVersion.includes("-");
|
|
31
31
|
if (!isPrerelease) {
|
|
32
32
|
try {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import colors from "piccolore";
|
|
2
2
|
import {
|
|
3
3
|
collapseDuplicateLeadingSlashes,
|
|
4
|
+
collapseDuplicateSlashes,
|
|
4
5
|
prependForwardSlash,
|
|
5
6
|
removeTrailingForwardSlash
|
|
6
7
|
} from "@astrojs/internal-helpers/path";
|
|
@@ -28,7 +29,6 @@ import {
|
|
|
28
29
|
import { getParams, getProps } from "../render/index.js";
|
|
29
30
|
import { Rewrites } from "../rewrites/handler.js";
|
|
30
31
|
import { isRoute404or500, isRouteServerIsland } from "../routing/match.js";
|
|
31
|
-
import { normalizeUrl } from "../util/normalized-url.js";
|
|
32
32
|
import { MultiLevelEncodingError, validateAndDecodePathname } from "../util/pathname.js";
|
|
33
33
|
import { getOriginPathname, setOriginPathname } from "../routing/rewrite.js";
|
|
34
34
|
import { computePathnameFromDomain } from "../i18n/domain.js";
|
|
@@ -167,39 +167,45 @@ class FetchState {
|
|
|
167
167
|
this.request = request;
|
|
168
168
|
options ??= getRenderOptions(request);
|
|
169
169
|
this.routeData = options?.routeData;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
const self = this;
|
|
171
|
+
this.renderOptions = {
|
|
172
|
+
...options ?? {
|
|
173
|
+
addCookieHeader: false,
|
|
174
|
+
clientAddress: void 0,
|
|
175
|
+
prerenderedErrorPageFetch: fetch,
|
|
176
|
+
routeData: void 0,
|
|
177
|
+
waitUntil: void 0
|
|
178
|
+
},
|
|
179
|
+
get locals() {
|
|
180
|
+
return self.locals;
|
|
181
|
+
}
|
|
177
182
|
};
|
|
178
183
|
this.componentInstance = void 0;
|
|
179
184
|
this.slots = void 0;
|
|
180
185
|
const url = new URL(request.url);
|
|
186
|
+
const publicPathname = this.#normalizePathname(url.pathname);
|
|
187
|
+
const pathname = this.#computePathname(publicPathname);
|
|
188
|
+
url.pathname = publicPathname;
|
|
189
|
+
url.pathname = collapseDuplicateSlashes(url.pathname);
|
|
181
190
|
const domainPathname = computePathnameFromDomain(
|
|
182
191
|
request,
|
|
183
192
|
url,
|
|
184
193
|
pipeline.manifest.i18n,
|
|
185
194
|
pipeline.manifest.base,
|
|
186
195
|
pipeline.manifest.trailingSlash,
|
|
187
|
-
pipeline.logger
|
|
196
|
+
pipeline.logger,
|
|
197
|
+
pathname
|
|
188
198
|
);
|
|
189
199
|
if (domainPathname) {
|
|
190
200
|
this.#domainPathname = domainPathname;
|
|
191
|
-
|
|
192
|
-
this.pathname = decodeURI(domainPathname);
|
|
193
|
-
} catch {
|
|
194
|
-
this.pathname = domainPathname;
|
|
195
|
-
}
|
|
201
|
+
this.pathname = domainPathname;
|
|
196
202
|
} else {
|
|
197
|
-
this.pathname =
|
|
203
|
+
this.pathname = pathname;
|
|
198
204
|
}
|
|
199
205
|
this.timeStart = performance.now();
|
|
200
206
|
this.clientAddress = options?.clientAddress;
|
|
201
207
|
this.locals = options?.locals ?? {};
|
|
202
|
-
this.url =
|
|
208
|
+
this.url = url;
|
|
203
209
|
this.cookies = new AstroCookies(request);
|
|
204
210
|
if (pipeline.manifest.allowedDomains && pipeline.manifest.allowedDomains.length > 0 && !this.routeData?.prerender) {
|
|
205
211
|
this.#applyForwardedHeaders();
|
|
@@ -732,32 +738,37 @@ class FetchState {
|
|
|
732
738
|
this.#stripHtmlExtension();
|
|
733
739
|
}
|
|
734
740
|
/**
|
|
735
|
-
* Strips the pipeline's base from
|
|
736
|
-
*
|
|
737
|
-
* pathname if `decodeURI` throws.
|
|
741
|
+
* Strips the pipeline's base from a normalized request pathname and prepends
|
|
742
|
+
* a forward slash.
|
|
738
743
|
*
|
|
739
744
|
* Mirrors `BaseApp.removeBase`, including the
|
|
740
745
|
* `collapseDuplicateLeadingSlashes` fix that prevents middleware
|
|
741
746
|
* authorization bypass when the URL starts with `//`.
|
|
742
747
|
*/
|
|
743
|
-
#computePathname(
|
|
744
|
-
let pathname = collapseDuplicateLeadingSlashes(
|
|
748
|
+
#computePathname(normalizedPathname) {
|
|
749
|
+
let pathname = collapseDuplicateLeadingSlashes(normalizedPathname);
|
|
745
750
|
const base = this.pipeline.manifest.base;
|
|
746
751
|
if (pathname.startsWith(base)) {
|
|
747
752
|
const baseWithoutTrailingSlash = removeTrailingForwardSlash(base);
|
|
748
753
|
pathname = pathname.slice(baseWithoutTrailingSlash.length + 1);
|
|
749
754
|
}
|
|
750
|
-
|
|
755
|
+
return prependForwardSlash(pathname);
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Decodes and normalizes the public request pathname before deriving the
|
|
759
|
+
* separate pathname used for route matching.
|
|
760
|
+
*/
|
|
761
|
+
#normalizePathname(pathname) {
|
|
751
762
|
try {
|
|
752
|
-
|
|
763
|
+
pathname = validateAndDecodePathname(pathname);
|
|
753
764
|
} catch (e) {
|
|
754
765
|
if (e instanceof MultiLevelEncodingError) {
|
|
755
766
|
this.invalidEncoding = true;
|
|
756
|
-
|
|
767
|
+
} else {
|
|
768
|
+
this.pipeline.logger.error(null, e.toString());
|
|
757
769
|
}
|
|
758
|
-
this.pipeline.logger.error(null, e.toString());
|
|
759
|
-
return pathname;
|
|
760
770
|
}
|
|
771
|
+
return collapseDuplicateSlashes(pathname);
|
|
761
772
|
}
|
|
762
773
|
/**
|
|
763
774
|
* Reads X-Forwarded-Proto, X-Forwarded-Host, and X-Forwarded-Port
|
|
@@ -9,4 +9,4 @@ import type { AstroLogger } from '../logger/core.js';
|
|
|
9
9
|
* mapped to a locale — in which case normal pathname routing applies.
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
|
-
export declare function computePathnameFromDomain(request: Request, url: URL, i18n: SSRManifest['i18n'], base: SSRManifest['base'], trailingSlash: SSRManifest['trailingSlash'], logger: AstroLogger): string | undefined;
|
|
12
|
+
export declare function computePathnameFromDomain(request: Request, url: URL, i18n: SSRManifest['i18n'], base: SSRManifest['base'], trailingSlash: SSRManifest['trailingSlash'], logger: AstroLogger, pathnameFromRequest?: string): string | undefined;
|
package/dist/core/i18n/domain.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
removeTrailingForwardSlash
|
|
7
7
|
} from "@astrojs/internal-helpers/path";
|
|
8
8
|
import { normalizeTheLocale } from "../../i18n/path.js";
|
|
9
|
-
function computePathnameFromDomain(request, url, i18n, base, trailingSlash, logger) {
|
|
9
|
+
function computePathnameFromDomain(request, url, i18n, base, trailingSlash, logger, pathnameFromRequest) {
|
|
10
10
|
let pathname = void 0;
|
|
11
11
|
if (i18n && (i18n.strategy === "domains-prefix-always" || i18n.strategy === "domains-prefix-other-locales" || i18n.strategy === "domains-prefix-always-no-redirect")) {
|
|
12
12
|
let host = request.headers.get("X-Forwarded-Host");
|
|
@@ -32,14 +32,13 @@ function computePathnameFromDomain(request, url, i18n, base, trailingSlash, logg
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
if (locale) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
35
|
+
const requestPathname = pathnameFromRequest ?? removeBase(url.pathname, base);
|
|
36
|
+
pathname = prependForwardSlash(joinPaths(normalizeTheLocale(locale), requestPathname));
|
|
38
37
|
if (trailingSlash === "always") {
|
|
39
38
|
pathname = appendForwardSlash(pathname);
|
|
40
39
|
} else if (trailingSlash === "never") {
|
|
41
40
|
pathname = removeTrailingForwardSlash(pathname);
|
|
42
|
-
} else if (
|
|
41
|
+
} else if (requestPathname.endsWith("/")) {
|
|
43
42
|
pathname = appendForwardSlash(pathname);
|
|
44
43
|
}
|
|
45
44
|
}
|
package/dist/prefetch/index.js
CHANGED
|
@@ -144,7 +144,8 @@ function prefetch(url, opts) {
|
|
|
144
144
|
for (const [key, value] of Object.entries(internalFetchHeaders)) {
|
|
145
145
|
headers.set(key, value);
|
|
146
146
|
}
|
|
147
|
-
fetch(url, { priority: "low", headers })
|
|
147
|
+
fetch(url, { priority: "low", headers }).catch(() => {
|
|
148
|
+
});
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
151
|
function canPrefetchUrl(url, ignoreSlowConnection) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.2",
|
|
4
4
|
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "withastro",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"ci-info": "^4.4.0",
|
|
108
108
|
"clsx": "^2.1.1",
|
|
109
109
|
"common-ancestor-path": "^2.0.0",
|
|
110
|
-
"cookie": "^
|
|
110
|
+
"cookie": "^2.0.1",
|
|
111
111
|
"devalue": "^5.8.1",
|
|
112
112
|
"diff": "^8.0.3",
|
|
113
113
|
"dset": "^3.1.4",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"magic-string": "^0.30.21",
|
|
125
125
|
"magicast": "^0.5.2",
|
|
126
126
|
"mrmime": "^2.0.1",
|
|
127
|
-
"neotraverse": "^0.
|
|
127
|
+
"neotraverse": "^1.0.1",
|
|
128
128
|
"obug": "^2.1.1",
|
|
129
129
|
"p-limit": "^7.3.0",
|
|
130
130
|
"p-queue": "^9.1.0",
|
|
@@ -146,9 +146,9 @@
|
|
|
146
146
|
"xxhash-wasm": "^1.1.0",
|
|
147
147
|
"yargs-parser": "^22.0.0",
|
|
148
148
|
"zod": "^4.3.6",
|
|
149
|
+
"@astrojs/markdown-satteri": "0.3.4",
|
|
149
150
|
"@astrojs/internal-helpers": "0.10.1",
|
|
150
|
-
"@astrojs/telemetry": "3.3.3"
|
|
151
|
-
"@astrojs/markdown-satteri": "0.3.4"
|
|
151
|
+
"@astrojs/telemetry": "3.3.3"
|
|
152
152
|
},
|
|
153
153
|
"optionalDependencies": {
|
|
154
154
|
"sharp": "^0.34.0 || ^0.35.0"
|