Skip to content

Normalize explicit true values for the robots CLI option - #981

Open
Doomguy-BFG9000 wants to merge 1 commit into
http-party:masterfrom
Doomguy-BFG9000:fix/robots-true-cli-value
Open

Doomguy-BFG9000 wants to merge 1 commit into
http-party:masterfrom
Doomguy-BFG9000:fix/robots-true-cli-value

Conversation

@Doomguy-BFG9000

Copy link
Copy Markdown

http-server --robots true passed the string "true" through to the server, which treated it as custom robots content. Requests to /robots.txt therefore returned true rather than the documented default rules.

Normalize that explicit CLI value to boolean true after selecting the short or long option. Custom content strings and the programmatic server API retain their existing behavior.

Relevant issues

Fixes #825.

Validation

Windows, Node.js 25.2.1:

  • Unchanged CLI baseline: 40 assertions pass.
  • New regression cases against unchanged production: 72 assertions pass, 3 fail. The failures reproduce -r true, --robots true, and --robots=true; bare flags and custom content controls pass.
  • npm test -- --jobs=2 after the fix: 562 assertions pass, 1 skip, 0 failures across the full suite.
  • Seven CLI forms exercise real loopback HTTP responses and verify the content type and exact response body.
  • git diff --check passes.
Contributor checklist
  • Provide tests for the changes
  • The pull request is being made against the master branch

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.

robots.txt flag is not working

1 participant