Skip to content

fix: match numeric header expectations - #913

Open
sricharanreddycheruku wants to merge 1 commit into
forwardemail:masterfrom
sricharanreddycheruku:new/match-numeric-header-expectations
Open

sricharanreddycheruku wants to merge 1 commit into
forwardemail:masterfrom
sricharanreddycheruku:new/match-numeric-header-expectations

Conversation

@sricharanreddycheruku

Copy link
Copy Markdown

Numeric header expectations are already accepted by expect(), but matching values fail because HTTP headers are strings. For example, .expect('Content-Length', 3) reports expected "Content-Length" of "3", got "3".

Convert only numeric expectations to strings before the existing comparison. String and regular-expression expectations retain their behavior. The README now lists the numeric argument type.

Four HTTP regression cases cover matching Content-Length, zero, negative and fractional values. All four fail on unchanged source. A control rejects "03" when expecting 3, and the existing incorrect-number test remains intact.

Validation on Linux:

  • npm test passes on Node 18.20.8, 20.20.0, 22.19.0 and 24.19.0. Each run includes ESLint, all 142 Mocha tests, leak checks and NYC coverage, with no skipped tests.
  • npm run coverage passes on Node 24.19.0.
  • Conventional commitlint and git diff --check pass.

Windows, macOS and upstream CI have not been run for this change.

Checklist

  • I have ensured my pull request is not behind the main or master branch of the original repository.
  • I have rebased all commits where necessary so that reviewing this pull request can be done without having to merge it first.
  • I have written a commit message that passes commitlint linting.
  • I have ensured that my code changes pass linting tests.
  • I have ensured that my code changes pass unit tests.
  • I have described my pull request and the reasons for code changes along with context if necessary.

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