-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
feat: handle static assets in case-sensitive manner #10475
Conversation
Hmm. I might need some help with this one. The test passes on Linux, which is what I run, so this will be very difficult for me to get that test working since I don't have a way to reproduce the error |
the check "file exists with correct case" on case insensitive fs may be usefule outside of the static middleware so maybe move it to a util and add a unit test too? there is vite/packages/vite/src/node/utils.ts Line 218 in ee3231c
The current implementation recurses to check all parent directory names separately, doing readDir calls to list files. This could be a bit more expensive on the disk operation side, so may be worth caching the positive results in a set? |
The error response is
which seems like some extra handling for script files in public dir. If you use |
c6c2da6
to
e830803
Compare
Thank you so much for taking a look at this!
Are you sure? I just changed it to that and the CI is failing still. Though now it gets a 200 rather than 500, which I suppose is an improvement. It's curious because I stole this code from SvelteKit and it has a test for it that passes. |
The previous fail was during |
Ah, thanks!! I really appreciate the help @dominikg! I've implemented it for preview as well so the tests are passing now! |
bed03db
to
e6846e3
Compare
e6846e3
to
77b51ad
Compare
77b51ad
to
118e36d
Compare
I moved the method to I also leveraged the |
I had a look at the Todo about those double slashes: First of all, the behaviour (double slashes) is not new. Apparently They occur because viteTestUrl is set here to something like 'http://localhost:4173/' (with trailing slash) and many (most? all?) URLs in the tests are build like So either change all the tests not to include that slash, change |
Thanks! I added it to |
We discussed this in the last team meeting and agree with this. Just needs a review and it's good to go. |
packages/vite/src/node/utils.ts
Outdated
const pathname = decodeURIComponent( | ||
new URL(url.startsWith('//') ? url.substring(1) : url, 'http://example.com') | ||
.pathname | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like sirv is able to handle //
because it uses @polka/url
. We could probably use that too as it caches the result to req
, but also something we can improve later.
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Thanks for the review @bluwy! I've addressed your comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Let's merge so we give more time to other projects to test this.
Testing Vite 4 with îles. An unintended effect of #10475 is that This is important to be able to locally preview sites that will be deployed using Ideally, frameworks like îles should be able to override |
Description
Enforce case sensitivity so that your code works if you develop on Mac / Windows and then deploy to Linux. It also becomes easier to work on a code base where people on the team are using different OS.
Closes #9260
Additional context
Discussed in
#contributing
on Oct 14: https://discord.com/channels/804011606160703521/804439875226173480/1030501340373336144What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).