Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pages-shared] Remove extension name check when generating response #4051

Merged
merged 1 commit into from
Nov 6, 2023

Conversation

taoky
Copy link
Contributor

@taoky taoky commented Sep 28, 2023

Fixes #2779.

What this PR solves / how to test:

Using regex for filename to check whether it is a directory or not is broken, and current regex logic /\/.+\.[a-z0-9]+$/i.test(path) causes troubles for dir filenames like:

By removing the extension check, workers could always check whether ${pathname}/index.html exists.

Associated docs issue(s)/PR(s):

  • N/A

Author has included the following, where applicable:

Reviewer is to perform the following, as applicable:

  • Checked for inclusion of relevant tests
  • Checked for inclusion of a relevant changeset
  • Checked for creation of associated docs updates
  • Manually pulled down the changes and spot-tested

Note for PR author:

We want to celebrate and highlight awesome PR review! If you think this PR received a particularly high-caliber review, please assign it the label highlight pr review so future reviewers can take inspiration and learn from it.

@changeset-bot
Copy link

changeset-bot bot commented Sep 28, 2023

🦋 Changeset detected

Latest commit: 41294df

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/pages-shared Minor

Not sure what this means? Click here to learn what changesets are.

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

@taoky taoky changed the title Remove extension name check when generating response [pages-shared] Remove extension name check when generating response Sep 28, 2023
@taoky taoky marked this pull request as ready for review September 28, 2023 10:33
@taoky taoky requested a review from a team as a code owner September 28, 2023 10:33
@taoky
Copy link
Contributor Author

taoky commented Sep 28, 2023

I'm not sure how to add a corresponding test to pages-shared. However, I have tested this locally with wrangler pages dev + vercel/next.js#56090 (comment) and I think that it works.

@lrapoport-cf lrapoport-cf added pages Relating to Pages awaiting Cloudflare response Awaiting response from workers-sdk maintainer team labels Oct 9, 2023
@lrapoport-cf
Copy link
Contributor

hey @nevikashah :) can someone on your team please take a look at this?

@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2023

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6337663359/npm-package-wrangler-4051

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6337663359/npm-package-wrangler-4051

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6337663359/npm-package-wrangler-4051 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/6337663359/npm-package-cloudflare-pages-shared-4051

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.10.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare 3.20230922.0 3.20230922.0
workerd 1.20230922.0 1.20230922.0
workerd --version 1.20230922.0 2023-09-22

|

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@codecov
Copy link

codecov bot commented Oct 9, 2023

Codecov Report

Merging #4051 (41294df) into main (78e9397) will increase coverage by 0.03%.
Report is 45 commits behind head on main.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4051      +/-   ##
==========================================
+ Coverage   75.02%   75.06%   +0.03%     
==========================================
  Files         216      216              
  Lines       12026    12026              
  Branches     3115     3115              
==========================================
+ Hits         9023     9027       +4     
+ Misses       3003     2999       -4     

see 3 files with indirect coverage changes

Copy link
Contributor

@jahands jahands left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!
The tests for this are currently internal, unfortunately. Will add tests for this there.

@1000hz 1000hz merged commit 4578d64 into cloudflare:main Nov 6, 2023
26 checks passed
@workers-devprod workers-devprod mentioned this pull request Nov 6, 2023
@erictor
Copy link

erictor commented Apr 9, 2024

I have a web site that uses IIS on a hosted platform and is fronted by Cloudflare. I just tested this on 2024-04-09. I have a user account for my website registered on my website for testing purposes, with the username "my.name". Right now, if I browse to mywebsite.com/my.name/ the route successfully displays the profile of the my.name user. If I browse to mywebsite.com/my.name without the ending-slash, an HTTP ERROR 404 occurs.

@erictor
Copy link

erictor commented Apr 9, 2024

I should add that I have other 'registered users' on the site with usernames that don't have a period in the username and they work fine with or without an ending-slash. I'm not so sure this is a 'Cloudflare-specific issue' with regards to my website, I'm thinking it's an issue with IIS, and those who have direct access to the IIS server can configure something to solve this. However I'm using shared hosting and I don't have the ability to specifically configure IIS. So, I want Microsoft to give me a solution through web.config (they don't appear to) or I was hoping perhaps Cloudflare could provide an answer to this -- like maybe let me set a configuration to automatically append a slash to the end of a URL that has a period in it, before forwarding the request on to my shared hosting that uses IIS.

@taoky
Copy link
Contributor Author

taoky commented Apr 9, 2024

I have a web site that uses IIS on a hosted platform and is fronted by Cloudflare. I just tested this on 2024-04-09. I have a user account for my website registered on my website for testing purposes, with the username "my.name". Right now, if I browse to mywebsite.com/my.name/ the route successfully displays the profile of the my.name user. If I browse to mywebsite.com/my.name without the ending-slash, an HTTP ERROR 404 occurs.

This works with wrangler pages dev, but it's not so on deployed Cloudflare Pages... I have no idea what is missing here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting Cloudflare response Awaiting response from workers-sdk maintainer team pages Relating to Pages
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

🐛 BUG: Getting 404 on URL that contains a dot and no trailing slash
6 participants