Skip to content

fix: detect +xml content types as text - #612

Open
Meliceanu wants to merge 1 commit into
unjs:mainfrom
Meliceanu:fix/detect-xml-response-type
Open

fix: detect +xml content types as text#612
Meliceanu wants to merge 1 commit into
unjs:mainfrom
Meliceanu:fix/detect-xml-response-type

Conversation

@Meliceanu

@Meliceanu Meliceanu commented Jul 20, 2026

Copy link
Copy Markdown

Fixes #597.

detectResponseType only treated a fixed set of content types as text (application/xml, application/xhtml and so on) plus anything starting with text/. Subtypes with a +xml suffix like application/rss+xml or application/atom+xml fell through to blob, so an RSS feed came back as a Blob instead of a string.

This adds a +xml suffix check alongside the existing ones, mirroring how JSON already matches +json subtypes. Added a test that an application/rss+xml response is parsed as text.

Summary by CodeRabbit

  • Bug Fixes
    • Improved response handling for XML-based content types, ensuring formats such as RSS are returned as readable text.
  • Tests
    • Added coverage for responses using +xml media types.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e28558ac-c23b-4c04-9fe7-91ad69f0eac4

📥 Commits

Reviewing files that changed from the base of the PR and between 1dbc37f and 9c65710.

📒 Files selected for processing (2)
  • src/utils.ts
  • test/index.test.ts

📝 Walkthrough

Walkthrough

detectResponseType now classifies media types ending in +xml as text. Tests add an RSS endpoint returning application/rss+xml and verify $fetch returns its payload as a string.

Changes

RSS text detection

Layer / File(s) Summary
Text detection and RSS validation
src/utils.ts, test/index.test.ts
detectResponseType recognizes +xml media types as text, and an RSS endpoint plus Vitest case validate the behavior for application/rss+xml.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: treating +xml content types as text.
Linked Issues check ✅ Passed The code and test address #597 by returning application/rss+xml as text and broadening XML subtype detection.
Out of Scope Changes check ✅ Passed The changes stay focused on response type detection and a matching test, with no unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RSS feed with application/rss+xml returned as Blob instead of text

1 participant