Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/cold-bugs-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@cloudflare/pages-shared": minor
---

fix: remove extension name check when generating response

Current regex logic to check whether a pathname is a file (has file extension) is causing trouble for some websites, and now \${pathname}/index.html is always checked before returning notFound().
6 changes: 0 additions & 6 deletions packages/pages-shared/asset-server/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,6 @@ export async function generateHandler<
);
} else if ((assetEntry = await findAssetEntryForPath(`${pathname}.html`))) {
return serveAsset(assetEntry);
} else if (hasFileExtension(pathname)) {
return notFound();
}

if ((assetEntry = await findAssetEntryForPath(`${pathname}/index.html`))) {
Expand Down Expand Up @@ -626,10 +624,6 @@ function isCacheable(request: Request) {
return !request.headers.has("authorization") && !request.headers.has("range");
}

function hasFileExtension(path: string) {
return /\/.+\.[a-z0-9]+$/i.test(path);
}

// Parses a request URL hostname to determine if the request
// is from a project served in "preview" mode.
function isPreview(url: URL): boolean {
Expand Down