Skip to content

Detect XML structured suffix response types - #616

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

Detect XML structured suffix response types#616
deepakganesh78 wants to merge 1 commit into
unjs:mainfrom
deepakganesh78:fix/issue597-xml-response-type

Conversation

@deepakganesh78

@deepakganesh78 deepakganesh78 commented Jul 26, 2026

Copy link
Copy Markdown

Fixes #597.

detectResponseType only recognized a small set of exact XML media types. Structured syntax suffix types such as application/rss+xml, application/atom+xml, application/xhtml+xml, and image/svg+xml therefore fell through to blob instead of being decoded as text.

This adds XML media-type detection for application/*+xml and image/*+xml, while retaining the existing text/* handling. Tests cover RSS, Atom, XHTML, SVG, SOAP with parameters, case-insensitive headers, and regression guards for JSON, SSE, and binary content.

Validation:

  • vitest run --coverage — 35 passed before final edge-case additions
  • targeted vitest run test/index.test.ts — 37 passed
  • ESLint and Prettier checks passed for both changed files

The repository-wide Prettier command reports pre-existing formatting differences in 16 untouched files on this Windows checkout; all changed files pass the same checks.

Summary by CodeRabbit

  • Bug Fixes

    • Improved response handling for XML-based content types, including RSS, Atom, and vendor-specific XML formats.
    • Preserved existing handling for JSON, binary, and streaming responses.
  • Tests

    • Added coverage to verify XML content is correctly treated as text.

Treat RSS, Atom, XHTML, SVG, and other +xml media types as text while preserving JSON, event stream, and binary detection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jul 26, 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 Plus

Run ID: cc7e881a-03bf-4ea0-93ca-7c5f5099ad3d

📥 Commits

Reviewing files that changed from the base of the PR and between 1dbc37f and 8bc23bb.

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

📝 Walkthrough

Walkthrough

detectResponseType() now classifies XML-related Content-Type values, including application/*+xml, as text responses. Tests cover XML variants and confirm existing blob, JSON, and stream classifications remain unchanged.

Changes

XML response detection

Layer / File(s) Summary
XML content-type handling and validation
src/utils.ts, test/index.test.ts
Adds XML content-type matching to detectResponseType() and tests XML, RSS, Atom, SVG, vendor-cased, and existing non-text classifications.

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

Possibly related PRs

  • unjs/ofetch#612: Updates the same response-type detection logic and adds coverage for XML and +xml content types.
🚥 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 describes the main change: improving XML structured suffix response type detection.
Linked Issues check ✅ Passed The XML suffix detection change covers the reported application/rss+xml blob-to-text bug in #597.
Out of Scope Changes check ✅ Passed The code and tests stay focused on response-type detection and regression coverage for the XML suffix fix.
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

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