Skip to content

Conversation

alxkm
Copy link
Contributor

@alxkm alxkm commented Oct 12, 2025

This PR adds support for detecting MIME types from URLs that contain query parameters.

Changes

Implementation fix:

  • Changed getMimeType(URI uri) to use uri.getPath() instead of uri.toString()
  • This strips query parameters before detecting the file extension
  • Ensures URLs like https://example.com/image.png?version=1.2 correctly detect as image/png

Test coverage:

  • Added test verifying MIME type detection works with query parameters
  • Tests both URI and URL inputs with query strings
  • Validates that file extension is correctly extracted from the path

Rationale

Previously, URLs with query parameters (e.g., image.jpg?version=1.2) would fail because the query string was included in MIME type detection. By using getPath() instead of toString(), we now strip query parameters and correctly detect the file extension.

Co-authored-by: Oleksandr Klymenko <alexanderklmn@gmail.com>
Signed-off-by: Oleksandr Klymenko <alexanderklmn@gmail.com>
@ilayaperumalg ilayaperumalg added this to the 1.1.0.M4 milestone Oct 13, 2025
@ilayaperumalg
Copy link
Member

@alxkm Thanks for the PR adding test coverage!

Co-authored-by: Oleksandr Klymenko <alexanderklmn@gmail.com>
Signed-off-by: Oleksandr Klymenko <alexanderklmn@gmail.com>
@alxkm alxkm changed the title test: Add edge case and validation tests for MimeTypeDetector feat: Add support for URLs with query parameters in MimeTypeDetector Oct 13, 2025
@ericbottard
Copy link
Member

Merged in main via 3f79373

Thanks for your contribution @alxkm !

@ericbottard ericbottard self-assigned this Oct 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants