pingdotgg / uploadthing

File uploads for modern web devs
https://uploadthing.com
MIT License
4.26k stars 315 forks source link

Added `application/x-zip-compressed` and .reg files #1034

Closed occorune closed 5 days ago

occorune commented 3 weeks ago

Summary by CodeRabbit

changeset-bot[bot] commented 3 weeks ago

🦋 Changeset detected

Latest commit: d659c2ecd8bd1eee89184b15b946276c556d1997

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

This PR includes changesets to release 9 packages | Name | Type | | ----------------------- | ----- | | @uploadthing/mime-types | Minor | | @uploadthing/shared | Patch | | uploadthing | Patch | | @uploadthing/expo | Patch | | @uploadthing/react | Patch | | @uploadthing/solid | Patch | | @uploadthing/svelte | Patch | | @uploadthing/vue | Patch | | @uploadthing/nuxt | Patch |

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

vercel[bot] commented 3 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-uploadthing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 28, 2024 2:00am
1 Skipped Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **legacy-docs-uploadthing** | ⬜️ Ignored ([Inspect](https://vercel.com/pinglabs/legacy-docs-uploadthing/H4aeXo8VwogmYNrzcrAwcZvZqsp4)) | [Visit Preview](https://legacy-docs-uploadthing-git-fork-occorune-main-pinglabs.vercel.app) | | Oct 28, 2024 2:00am |
coderabbitai[bot] commented 3 weeks ago

Walkthrough

This pull request introduces new MIME types to enhance the application's file format handling capabilities. Specifically, it adds support for the application/x-zip-compressed MIME type for ZIP files and updates the text/plain MIME type to include the .reg file extension, allowing for better recognition and processing of these file formats.

Changes

File Path Change Summary
.changeset/fuzzy-cups-enjoy.md Added new MIME types: x-zip-compressed and .reg.
packages/mime-types/src/application.ts Added MIME type "application/x-zip-compressed" with properties source: "iana" and extensions: ["zip"].
packages/mime-types/src/text.ts Updated text/plain extensions from ["txt", "text", "conf", "def", "list", "log", "in", "ini"] to include "reg".

Possibly related PRs

Suggested reviewers

Poem

🐰 In the meadow, files take flight,
With new types, they shine so bright.
ZIPs and REGs now find their way,
In our app, they dance and play!
Hooray for formats, fresh and new,
A joyful hop, just for you! 🌼✨


📜 Recent review details **Configuration used: CodeRabbit UI** **Review profile: CHILL**
📥 Commits Files that changed from the base of the PR and between f7a6b903b6f5089890553a9d02b4ac3586326e26 and d659c2ecd8bd1eee89184b15b946276c556d1997.
📒 Files selected for processing (3) * .changeset/fuzzy-cups-enjoy.md (1 hunks) * packages/mime-types/src/application.ts (1 hunks) * packages/mime-types/src/text.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1) * .changeset/fuzzy-cups-enjoy.md
🔇 Additional comments (2)
packages/mime-types/src/text.ts (1)
`38-38`: **LGTM! Adding .reg extension to text/plain is appropriate.** The addition aligns well with other configuration file extensions like .conf and .ini that are already handled as plain text. This allows safe viewing of registry files while maintaining consistency with similar file types. Let's verify if there are any existing MIME type definitions for .reg files to avoid conflicts:
✅ Verification successful **Both changes are properly implemented and do not conflict** The verification confirms that: 1. The .reg extension is correctly added to text/plain MIME type with no conflicts in other MIME types 2. The application/x-zip-compressed MIME type is properly defined with .zip extension Both objectives from the PR are implemented correctly and do not have any conflicts or issues.
🏁 Scripts executed The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Search for any existing .reg file extension definitions rg '"reg"' --type ts ``` Length of output: 137 --- Script: ```shell #!/bin/bash # Let's check for any application/x-zip-compressed related changes in the codebase rg -i "x-zip|zip-compressed" --type ts # Also check for any other potential .reg extension mappings in the codebase ast-grep --pattern 'extensions: [$$$"reg"$$$]' ``` Length of output: 164 --- Script: ```shell #!/bin/bash # Let's check the content of application.ts to see the x-zip-compressed definition cat packages/mime-types/src/application.ts ``` Length of output: 58348
packages/mime-types/src/application.ts (1)
`18-21`: **Verify MIME type necessity and IANA registration.** There are potential concerns with this addition: 1. This MIME type appears to overlap with the existing `application/zip` type (line ~1000) which already handles `.zip` files. Having two MIME types for the same extension could lead to ambiguity in content type detection. 2. While the source is marked as "iana", I couldn't verify this MIME type in the IANA registry. It appears to be a legacy MIME type primarily used by older versions of Internet Explorer. Consider: 1. Using the standard `application/zip` MIME type instead, as it's the official IANA-registered MIME type for ZIP files. 2. If this MIME type must be supported for legacy reasons, add a code comment explaining why both MIME types are needed.
✅ Verification successful Let me verify the presence of `application/zip` and check its registration with IANA as well. --- **Both MIME types are valid and registered with IANA** While both `application/zip` and `application/x-zip-compressed` are registered with IANA and can handle `.zip` files, this is actually a valid use case. The `application/x-zip-compressed` MIME type is commonly used in legacy systems and web browsers, particularly in HTTP responses. Having both types ensures broader compatibility across different systems and browsers. Consider adding a comment to document this intentional duplication: ```typescript // Legacy MIME type for ZIP files, commonly used by older browsers "application/x-zip-compressed": { source: "iana", extensions: ["zip"], }, ```
🏁 Scripts executed The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Verify if this MIME type is registered with IANA curl -s https://www.iana.org/assignments/media-types/application/x-zip-compressed > /dev/null if [ $? -eq 0 ]; then echo "MIME type is registered with IANA" else echo "MIME type is not registered with IANA" fi # Check for existing usage of this MIME type in the codebase rg -l "application/x-zip-compressed" ``` Length of output: 254 --- Script: ```shell #!/bin/bash # Search for application/zip in the codebase rg "application/zip" -A 2 packages/mime-types/src/application.ts # Verify if application/zip is registered with IANA curl -s https://www.iana.org/assignments/media-types/application/zip > /dev/null if [ $? -eq 0 ]; then echo "application/zip is registered with IANA" else echo "application/zip is not registered with IANA" fi ``` Length of output: 310
--- Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
❤️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , please review it.` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (Invoked using PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
juliusmarminge commented 5 days ago

Stale. Reopen with requested fixes