Skip to content

fix: correct MIME type of .txt files (ref: #6762)#7111

Merged
lucasfernog merged 8 commits intotauri-apps:devfrom
reupen:fix/txt-mime-type
Jun 5, 2023
Merged

fix: correct MIME type of .txt files (ref: #6762)#7111
lucasfernog merged 8 commits intotauri-apps:devfrom
reupen:fix/txt-mime-type

Conversation

@reupen
Copy link
Contributor

@reupen reupen commented Jun 1, 2023

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Docs
  • New Binding issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes, and the changes were approved in issue #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.
  • I have added a convincing reason for adding this feature, if necessary

Other information

This sets the MIME type for .txt files as text/plain instead of text/html. See #6762 for more details. (Whether text/html is always the right fallback is also a question, but I haven't done anything about that here.)

I also moved MP4 up to its correct place alphabetically in a few places.

@reupen reupen marked this pull request as ready for review June 1, 2023 21:41
@reupen reupen requested a review from a team as a code owner June 1, 2023 21:41
wusyong
wusyong previously approved these changes Jun 2, 2023
@FabianLars
Copy link
Member

I wonder if we should use Self::Txt as a general fallback instead of Self::Html 🤔 Not sure what depends on that though so maybe something to think about later when Lucas is back.

@reupen
Copy link
Contributor Author

reupen commented Jun 2, 2023

Pushed a fixup to fix the linter error. Unfortunately the 'test core' jobs are failing with:

error: package `cargo_toml v0.15.3` cannot be built because it requires rustc 1.64 or newer, while the currently active rustc version is 1.60.0

@FabianLars
Copy link
Member

i want to cry 😂

@FabianLars
Copy link
Member

Can you add the package to this list: https://github.com/tauri-apps/tauri/blob/dev/.github/workflows/test-core.yml#L95 pinning it to 0.15.2 please?

@reupen
Copy link
Contributor Author

reupen commented Jun 2, 2023

Done. It was cargo update -p cargo_toml:0.15.3 --precise 0.15.2 due to:

error: There are multiple `cargo_toml` packages in your project, and the specification `cargo_toml` is ambiguous.
Please re-run this command with `-p <spec>` where `<spec>` is one of the following:
  cargo_toml:0.11.8
  cargo_toml:0.15.3

@reupen
Copy link
Contributor Author

reupen commented Jun 2, 2023

Okay, now there's that other Clippy failure.

I can reproduce the tauri-codegen warning on dev by running cargo clippy --manifest-path core/tauri/Cargo.toml -- -D warnings. Since it's set to fail on warnings, I assume that's the problem rather than the PR-from-fork stuff.

@FabianLars
Copy link
Member

Yeah, don't worry about it. Since your change doesn't trigger it we can fix it in another PR :)

@lucasfernog
Copy link
Member

For Tauri itself I think it's fine to change the default fallback to txt (I hope the asset will always have the .html extension), though for users it might be a little weird. The fallback for tauri://localhost should be indeed html instead of txt.

@lucasfernog
Copy link
Member

I'm thinking about it and it should be a separate PR (maybe even targetting v2 instead with a better way of handling this).

@lucasfernog lucasfernog merged commit 85e77fb into tauri-apps:dev Jun 5, 2023
@FabianLars
Copy link
Member

Why though? When would falling back to text be worse than falling back to html? Or different: When do we want to send html for non html files?

Genuine question btw, i'm so out of the loop on this topic by know that i can't think of a use-case right now.

@lucasfernog
Copy link
Member

MimeType::parse_from_uri is used when we can't determine the mime type from the file contents (which is always the case unless we do some custom html detection logic). When we receive a request to tauri://localhost, we want to serve it as HTML instead of plain text (I think in some contexts that is required).

@FabianLars
Copy link
Member

hmm, i thought we always tried to load index.html in these cases, or well, i guess we do but the other way around? idk, probably not much of a problem anyway now that we handle text files 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🔎 In audit

Development

Successfully merging this pull request may close these issues.

4 participants