astro 7.1.0 → 7.1.1

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.
@@ -1,6 +1,6 @@
1
1
  class BuildTimeAstroVersionProvider {
2
2
  // Injected during the build through esbuild define
3
- version = "7.1.0";
3
+ version = "7.1.1";
4
4
  }
5
5
  export {
6
6
  BuildTimeAstroVersionProvider
@@ -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.0") {
199
+ if (previousAstroVersion && previousAstroVersion !== "7.1.1") {
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.0") {
208
- this.#store.metaStore().set("astro-version", "7.1.0");
207
+ if ("7.1.1") {
208
+ this.#store.metaStore().set("astro-version", "7.1.1");
209
209
  }
210
210
  if (currentConfigDigest) {
211
211
  this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "7.1.0";
1
+ const ASTRO_VERSION = "7.1.1";
2
2
  const ASTRO_GENERATOR = `Astro v${ASTRO_VERSION}`;
3
3
  const ASTRO_ERROR_HEADER = "X-Astro-Error";
4
4
  const DEFAULT_404_COMPONENT = "astro-default-404.astro";
@@ -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.0";
29
+ const currentVersion = "7.1.1";
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";
@@ -178,28 +178,29 @@ class FetchState {
178
178
  this.componentInstance = void 0;
179
179
  this.slots = void 0;
180
180
  const url = new URL(request.url);
181
+ const publicPathname = this.#normalizePathname(url.pathname);
182
+ const pathname = this.#computePathname(publicPathname);
183
+ url.pathname = publicPathname;
184
+ url.pathname = collapseDuplicateSlashes(url.pathname);
181
185
  const domainPathname = computePathnameFromDomain(
182
186
  request,
183
187
  url,
184
188
  pipeline.manifest.i18n,
185
189
  pipeline.manifest.base,
186
190
  pipeline.manifest.trailingSlash,
187
- pipeline.logger
191
+ pipeline.logger,
192
+ pathname
188
193
  );
189
194
  if (domainPathname) {
190
195
  this.#domainPathname = domainPathname;
191
- try {
192
- this.pathname = decodeURI(domainPathname);
193
- } catch {
194
- this.pathname = domainPathname;
195
- }
196
+ this.pathname = domainPathname;
196
197
  } else {
197
- this.pathname = this.#computePathname(url);
198
+ this.pathname = pathname;
198
199
  }
199
200
  this.timeStart = performance.now();
200
201
  this.clientAddress = options?.clientAddress;
201
202
  this.locals = options?.locals ?? {};
202
- this.url = normalizeUrl(url);
203
+ this.url = url;
203
204
  this.cookies = new AstroCookies(request);
204
205
  if (pipeline.manifest.allowedDomains && pipeline.manifest.allowedDomains.length > 0 && !this.routeData?.prerender) {
205
206
  this.#applyForwardedHeaders();
@@ -732,32 +733,37 @@ class FetchState {
732
733
  this.#stripHtmlExtension();
733
734
  }
734
735
  /**
735
- * Strips the pipeline's base from the request URL, prepends a forward
736
- * slash, and decodes the pathname. Falls back to the raw (not decoded)
737
- * pathname if `decodeURI` throws.
736
+ * Strips the pipeline's base from a normalized request pathname and prepends
737
+ * a forward slash.
738
738
  *
739
739
  * Mirrors `BaseApp.removeBase`, including the
740
740
  * `collapseDuplicateLeadingSlashes` fix that prevents middleware
741
741
  * authorization bypass when the URL starts with `//`.
742
742
  */
743
- #computePathname(url) {
744
- let pathname = collapseDuplicateLeadingSlashes(url.pathname);
743
+ #computePathname(normalizedPathname) {
744
+ let pathname = collapseDuplicateLeadingSlashes(normalizedPathname);
745
745
  const base = this.pipeline.manifest.base;
746
746
  if (pathname.startsWith(base)) {
747
747
  const baseWithoutTrailingSlash = removeTrailingForwardSlash(base);
748
748
  pathname = pathname.slice(baseWithoutTrailingSlash.length + 1);
749
749
  }
750
- pathname = prependForwardSlash(pathname);
750
+ return prependForwardSlash(pathname);
751
+ }
752
+ /**
753
+ * Decodes and normalizes the public request pathname before deriving the
754
+ * separate pathname used for route matching.
755
+ */
756
+ #normalizePathname(pathname) {
751
757
  try {
752
- return validateAndDecodePathname(pathname);
758
+ pathname = validateAndDecodePathname(pathname);
753
759
  } catch (e) {
754
760
  if (e instanceof MultiLevelEncodingError) {
755
761
  this.invalidEncoding = true;
756
- return pathname;
762
+ } else {
763
+ this.pipeline.logger.error(null, e.toString());
757
764
  }
758
- this.pipeline.logger.error(null, e.toString());
759
- return pathname;
760
765
  }
766
+ return collapseDuplicateSlashes(pathname);
761
767
  }
762
768
  /**
763
769
  * 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;
@@ -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
- pathname = prependForwardSlash(
36
- joinPaths(normalizeTheLocale(locale), removeBase(url.pathname, base))
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 (url.pathname.endsWith("/")) {
41
+ } else if (requestPathname.endsWith("/")) {
43
42
  pathname = appendForwardSlash(pathname);
44
43
  }
45
44
  }
@@ -270,7 +270,7 @@ function printHelp({
270
270
  message.push(
271
271
  linebreak(),
272
272
  ` ${bgGreen(black(` ${commandName} `))} ${green(
273
- `v${"7.1.0"}`
273
+ `v${"7.1.1"}`
274
274
  )} ${headline}`
275
275
  );
276
276
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "7.1.0",
3
+ "version": "7.1.1",
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",