Skip to content

fix: handle commas in static file paths#3770

Merged
bartlomieju merged 2 commits intodenoland:mainfrom
SebF33:fix/static-files-comma
Apr 22, 2026
Merged

fix: handle commas in static file paths#3770
bartlomieju merged 2 commits intodenoland:mainfrom
SebF33:fix/static-files-comma

Conversation

@SebF33
Copy link
Copy Markdown
Contributor

@SebF33 SebF33 commented Apr 11, 2026

Problem

After #3659, static file handling correctly supports spaces and encoded paths,
but filenames containing commas are not resolved.

Example:

  • File: foo,bar.css
  • Stored in cache as: /foo%2Cbar.css
  • Request: /foo,bar.css

This causes a mismatch and the static file is not found.

Cause

prepareStaticFile() stores file paths using URL encoding, while
static_files.ts compares against url.pathname without applying the same
normalization.

Solution

Normalize the incoming request pathname using the same encoding logic before
reading from the build cache.

Tests

Added static files - comma in pathname to verify that both of these resolve:

  • /foo,bar.css
  • /foo%2Cbar.css

SebF33 and others added 2 commits April 12, 2026 00:21
…duction

Move the decode/re-encode logic into a local `normalizePathname` helper
instead of importing `systemPathToUrlEncoded` from `dev_build_cache.ts`,
which pulls the entire dev module graph into the production middleware.
Also narrow the catch clause to only handle URIError.
Copy link
Copy Markdown
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@bartlomieju bartlomieju enabled auto-merge (squash) April 22, 2026 08:20
@bartlomieju bartlomieju merged commit 49c4be1 into denoland:main Apr 22, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants