astro 5.2.3 → 5.2.4

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.
@@ -153,7 +153,7 @@ ${contentConfig.error.message}`);
153
153
  logger.info("Content config changed");
154
154
  shouldClear = true;
155
155
  }
156
- if (previousAstroVersion && previousAstroVersion !== "5.2.3") {
156
+ if (previousAstroVersion && previousAstroVersion !== "5.2.4") {
157
157
  logger.info("Astro version changed");
158
158
  shouldClear = true;
159
159
  }
@@ -161,8 +161,8 @@ ${contentConfig.error.message}`);
161
161
  logger.info("Clearing content store");
162
162
  this.#store.clearAll();
163
163
  }
164
- if ("5.2.3") {
165
- await this.#store.metaStore().set("astro-version", "5.2.3");
164
+ if ("5.2.4") {
165
+ await this.#store.metaStore().set("astro-version", "5.2.4");
166
166
  }
167
167
  if (currentConfigDigest) {
168
168
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "5.2.3";
1
+ const ASTRO_VERSION = "5.2.4";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
4
4
  const REWRITE_DIRECTIVE_HEADER_VALUE = "yes";
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
22
22
  await telemetry.record([]);
23
23
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
24
24
  const logger = restart.container.logger;
25
- const currentVersion = "5.2.3";
25
+ const currentVersion = "5.2.4";
26
26
  const isPrerelease = currentVersion.includes("-");
27
27
  if (!isPrerelease) {
28
28
  try {
@@ -38,7 +38,7 @@ function serverStart({
38
38
  host,
39
39
  base
40
40
  }) {
41
- const version = "5.2.3";
41
+ const version = "5.2.4";
42
42
  const localPrefix = `${dim("\u2503")} Local `;
43
43
  const networkPrefix = `${dim("\u2503")} Network `;
44
44
  const emptyPrefix = " ".repeat(11);
@@ -276,7 +276,7 @@ function printHelp({
276
276
  message.push(
277
277
  linebreak(),
278
278
  ` ${bgGreen(black(` ${commandName} `))} ${green(
279
- `v${"5.2.3"}`
279
+ `v${"5.2.4"}`
280
280
  )} ${headline}`
281
281
  );
282
282
  }
@@ -14,7 +14,7 @@ import {
14
14
  UnsupportedExternalRedirect
15
15
  } from "../../errors/errors-data.js";
16
16
  import { AstroError } from "../../errors/index.js";
17
- import { removeLeadingForwardSlash, slash } from "../../path.js";
17
+ import { hasFileExtension, removeLeadingForwardSlash, slash } from "../../path.js";
18
18
  import { injectServerIslandRoute } from "../../server-islands/endpoint.js";
19
19
  import { resolvePages } from "../../util.js";
20
20
  import { ensure404Route } from "../astro-designed-error-pages.js";
@@ -145,10 +145,10 @@ function createFileBasedRoutes({ settings, cwd, fsMod }, logger) {
145
145
  } else {
146
146
  components.push(item.file);
147
147
  const component = item.file;
148
- const { trailingSlash } = settings.config;
148
+ const pathname = segments.every((segment) => segment.length === 1 && !segment[0].dynamic) ? `/${segments.map((segment) => segment[0].content).join("/")}` : null;
149
+ const trailingSlash = trailingSlashForPath(pathname, settings.config);
149
150
  const pattern = getPattern(segments, settings.config.base, trailingSlash);
150
151
  const generate = getRouteGenerator(segments, trailingSlash);
151
- const pathname = segments.every((segment) => segment.length === 1 && !segment[0].dynamic) ? `/${segments.map((segment) => segment[0].content).join("/")}` : null;
152
152
  const route = joinSegments(segments);
153
153
  routes.push({
154
154
  route,
@@ -178,6 +178,7 @@ function createFileBasedRoutes({ settings, cwd, fsMod }, logger) {
178
178
  }
179
179
  return routes;
180
180
  }
181
+ const trailingSlashForPath = (pathname, config) => pathname && hasFileExtension(pathname) ? "ignore" : config.trailingSlash;
181
182
  function createInjectedRoutes({ settings, cwd }) {
182
183
  const { config } = settings;
183
184
  const prerender = getPrerenderDefault(config);
@@ -190,10 +191,10 @@ function createInjectedRoutes({ settings, cwd }) {
190
191
  return getParts(s, component);
191
192
  });
192
193
  const type = resolved.endsWith(".astro") ? "page" : "endpoint";
193
- const { trailingSlash } = config;
194
+ const pathname = segments.every((segment) => segment.length === 1 && !segment[0].dynamic) ? `/${segments.map((segment) => segment[0].content).join("/")}` : null;
195
+ const trailingSlash = trailingSlashForPath(pathname, config);
194
196
  const pattern = getPattern(segments, settings.config.base, trailingSlash);
195
197
  const generate = getRouteGenerator(segments, trailingSlash);
196
- const pathname = segments.every((segment) => segment.length === 1 && !segment[0].dynamic) ? `/${segments.map((segment) => segment[0].content).join("/")}` : null;
197
198
  const params = segments.flat().filter((p) => p.dynamic).map((p) => p.content);
198
199
  const route = joinSegments(segments);
199
200
  routes.push({
@@ -4,20 +4,20 @@ import { writeHtmlResponse, writeRedirectResponse } from "./response.js";
4
4
  function trailingSlashMiddleware(settings) {
5
5
  const { trailingSlash } = settings.config;
6
6
  return function devTrailingSlash(req, res, next) {
7
- const url = req.url;
8
- const destination = collapseDuplicateTrailingSlashes(url, true);
9
- if (url && destination !== url) {
10
- return writeRedirectResponse(res, 301, destination);
11
- }
7
+ const url = new URL(`http://localhost${req.url}`);
12
8
  let pathname;
13
9
  try {
14
- pathname = decodeURI(new URL(url, "http://localhost").pathname);
10
+ pathname = decodeURI(url.pathname);
15
11
  } catch (e) {
16
12
  return next(e);
17
13
  }
18
14
  if (pathname.startsWith("/_") || pathname.startsWith("/@")) {
19
15
  return next();
20
16
  }
17
+ const destination = collapseDuplicateTrailingSlashes(pathname, true);
18
+ if (pathname && destination !== pathname) {
19
+ return writeRedirectResponse(res, 301, `${destination}${url.search}`);
20
+ }
21
21
  if (trailingSlash === "never" && pathname.endsWith("/") && pathname !== "/" || trailingSlash === "always" && !pathname.endsWith("/") && !hasFileExtension(pathname)) {
22
22
  const html = trailingSlashMismatchTemplate(pathname, trailingSlash);
23
23
  return writeHtmlResponse(res, 404, html);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "5.2.3",
3
+ "version": "5.2.4",
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",
@@ -159,9 +159,9 @@
159
159
  "zod": "^3.24.1",
160
160
  "zod-to-json-schema": "^3.24.1",
161
161
  "zod-to-ts": "^1.2.0",
162
- "@astrojs/internal-helpers": "0.5.0",
162
+ "@astrojs/telemetry": "3.2.0",
163
163
  "@astrojs/markdown-remark": "6.1.0",
164
- "@astrojs/telemetry": "3.2.0"
164
+ "@astrojs/internal-helpers": "0.5.1"
165
165
  },
166
166
  "optionalDependencies": {
167
167
  "sharp": "^0.33.3"