-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Make AssetPath::get_full_extension
work for non-UTF-8 file names.
#19974
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
base: main
Are you sure you want to change the base?
Conversation
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.
I like this fix, but two small requests:
- Please add a regression test.
- Please add a simple migration guide.
It looks like your PR is a breaking change, but you didn't provide a migration guide. Please review the instructions for writing migration guides, then expand or revise the content in the migration guides directory to reflect your changes. |
I'm on Linux. I'm not sure there's a way to write this in a platform-independent way. I think it works for Mac, too. I'm not sure about others. |
We could cfg flag the test based on the platform? @viridia or @andriyDev might have better advice. |
I wonder if this change is worth making... In the future, we expect to make AssetPath just hold a I think my (very weak) opinion is that we should not fix this since it's not where we want to go long term anyway? @alice-i-cecile thoughts? As for the cfg flagging the test, I can't think of anything other than using |
I share @andriyDev's concerns. The way that I have always seen assets as working is that assets should live in a virtual, platform-neutral filesystem that is backed by one or more actual, platform-specific filesystems. Part of the job of this virtual filesystem is to completely isolate any platform differences. This means that things like windows drive letters should be meaningless in an asset path; it's only the |
Objective
The expectation is that extensions will be UTF-8 in order to match asset loaders, but if the file name itself is not, it should still work. This fixes that.
Solution
This works on bytes and returns
&str
instead of allocating aString
. The changes outside of the function itself relate to the return type changing.Testing
cargo test --workspace --tests