Skip to content

Conversation

@tinas
Copy link
Contributor

@tinas tinas commented Dec 18, 2024

Summary

This PR addresses an issue where the content-type header check was case-sensitive, causing valid Content-Type values like Text/html to be rejected. The solution normalizes the content-type header using .toLowerCase() to ensure case-insensitive checks.

Reproduction Steps

  1. Make a request to a URL with a Content-Type header of Text/html; charset=utf-8.
  2. The scraper incorrectly throws an error:
Page must return a header content-type with text/
  1. Expected behavior: The scraper should successfully process URLs with case-insensitive Content-Type headers.

Changes Made

  • Updated the content-type check in the scraper logic to use toLowerCase().
  • Added a new test case for case-insensitive Content-Type values:
    • Content-Type: Text/html now works as expected.
  • Verified existing tests to ensure no regressions.

@jshemas
Copy link
Owner

jshemas commented Jan 14, 2025

Thanks for the PR!

@jshemas jshemas merged commit d6ae02d into jshemas:master Jan 14, 2025
4 checks passed
@jshemas
Copy link
Owner

jshemas commented Jan 14, 2025

Changes are live in open-graph-scraper@6.8.4

@tinas tinas deleted the fix-case-insensitive-content-type branch January 20, 2025 10:51
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.

2 participants