freeCodeCamp / freeCodeCamp/back-end-development-and-apis
Build a Web Server: Step 20 rejects valid curl command due to raw terminal input
- Dominant language
- JavaScript
- Stars
- 32
- Forks
- 217
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
Step 20 of Build a Web Server can reject the instructed command even when the server responds correctly.
## Reproduction
1. Complete Step 19 so that the server calls `response.end(request.url)`.
2. Restart the server with `node server.js`.
3. In another terminal, run:
```sh
curl http://localhost:3001/hello
```
4. Click Run Tests.
## Actual behavior
The test requires the exact substring `curl http://localhost:3001/hello` in `__helpers.getTemp()`. `getTemp()` reads `.logs/.temp.log`, which records raw terminal input. Terminal control sequences can split the command, so the substring assertion fails even though the command was run and the server returns a response.
## Expected behavior
The instructed command should pass regardless of terminal escape sequences.
## Proposed fix
Use `__helpers.getLastCommand()` and `__helpers.parseCli()` to verify that the command is `curl` and that its arguments include `http://localhost:3001/hello`. Step 18 already uses this approach for a similar curl assertion.
This is a remaining instance of the raw-terminal-log failure reported in #12, which was closed by commit 27aae2ab82a3e8ad843ecd93f405053fc8b1b17a.
Affected source: https://github.com/freeCodeCamp/back-end-development-and-apis/blob/4a47aa0d6bc57011b7c51f4a40cbadbbe2d98fc9/curriculum/locales/english/build-a-web-server.md#L600-L613
Forum report: https://forum.freecodecamp.org/t/build-a-web-server-build-a-web-server/799172
Contributor guide
Research direction
Open curriculum/locales/english/build-a-web-server.md around lines 600-613 and compare Step 20 with the similar curl assertion in Step 18. Review how __helpers.getLastCommand() and __helpers.parseCli() are used, then run the Step 20 tests with the instructed curl command. Done means terminal escape sequences no longer cause a valid command and response to fail.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100