Skip to content

Fix static build crash for file-extension endpoint routes with trailingSlash: "always"#17320

Merged
matthewp merged 1 commit into
mainfrom
triagebot/fix-17306
Jul 9, 2026
Merged

Fix static build crash for file-extension endpoint routes with trailingSlash: "always"#17320
matthewp merged 1 commit into
mainfrom
triagebot/fix-17306

Conversation

@astrobot-houston

Copy link
Copy Markdown
Contributor

Changes

  • Dynamic endpoint routes with a file extension (e.g. [...slug].png.ts) no longer fail with NoMatchingStaticPathFound during astro build when trailingSlash: "always" is set. stringifyParams() now mirrors the trailingSlashForPath() logic already used in route pattern generation: when a route is an endpoint with a file extension, trailing slash is forced to 'never', so generated paths (e.g. /og/foo.png) match the route pattern (e.g. /^\/og\/(.*?)\.png$/). The mismatch affected both ASCII and non-ASCII params.

Closes #17306

Testing

  • Added three unit tests in packages/astro/test/units/routing/get-params.test.ts covering:
    • Spread file-extension endpoint with non-ASCII params + trailingSlash: 'always' — path must not get a trailing slash and must match the route pattern.
    • Single dynamic file-extension endpoint ([name].json) with the same config.
    • Endpoint without a file extension still gets a trailing slash, confirming the fix is scoped correctly.

Docs

  • No docs update needed — this is a bug fix for existing static build behavior with no API surface change.

… in stringifyParams

When trailingSlash is 'always', stringifyParams (via getRouteGenerator)
was appending a trailing slash to endpoint paths with file extensions
(e.g. /og/foo.png/). But the route pattern for such endpoints is
generated with trailingSlash 'never' by trailingSlashForPath() in
create-manifest.ts (e.g. /^\/og\/(.*?)\.png$/). This mismatch caused
getParams() to fail matching, leading to NoMatchingStaticPathFound
during static builds.

Apply the same trailingSlashForPath logic in stringifyParams: when the
route is an endpoint with a file extension, force trailingSlash to
'never'.

Fixes #17306
@changeset-bot

changeset-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d27c2d3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added the pkg: astro Related to the core `astro` package (scope) label Jul 7, 2026
@winterqt

winterqt commented Jul 7, 2026

Copy link
Copy Markdown

Probably a dupe of #17246.

@codspeed-hq

codspeed-hq Bot commented Jul 7, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing triagebot/fix-17306 (d27c2d3) with main (437401e)

Open in CodSpeed

@matthewp matthewp merged commit 1b33c1f into main Jul 9, 2026
48 of 49 checks passed
@matthewp matthewp deleted the triagebot/fix-17306 branch July 9, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix verified Reporter confirmed the triage bot fix works pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Astro 7 static build fails for non-ASCII dynamic endpoint paths with trailingSlash always

3 participants