Skip to content

fix(isDataURI): accept case-insensitive URI schemes - #2893

Open
20ns wants to merge 1 commit into
validatorjs:masterfrom
20ns:fix/data-uri-scheme-case
Open

20ns wants to merge 1 commit into
validatorjs:masterfrom
20ns:fix/data-uri-scheme-case

Conversation

@20ns

@20ns 20ns commented Sep 20, 2026

Copy link
Copy Markdown

isDataURI('DATA:,Hello') returns false, although URI schemes are case-insensitive under RFC 3986 section 3.1. Mixed-case schemes such as DaTa:text/plain;base64,SGVsbG8= are rejected too.

Lowercase the existing five-character scheme slice before comparing it with data:. Add uppercase and mixed-case examples to the existing fixtures, including malformed inputs that must still be rejected.

Validation:

  • The added regression fixtures fail on the unchanged source and pass with the fix.
  • Node 24: npm test passes, including all builds, lint, and 323 tests.
  • Node 22: npm run test:ci passes, 323 tests.
  • 560 additional assertions pass across source, CommonJS, ES module, browser, and minified browser forms, covering all 16 case combinations of data with valid and invalid inputs.
  • 100% line and statement coverage; git diff --check passes.

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable; existing data URI contract is unchanged)
  • Tests written (where applicable)
  • References provided in PR (where applicable)

@codecov

codecov Bot commented Sep 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9ff3424) to head (89e9aac).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2893   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2599      2599           
  Branches       658       658           
=========================================
  Hits          2599      2599           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant