restify / restify/node-restify

prePath middleware strips multiple slashes to an empty string

Open
#1,953 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.7k
Forks
975
Avg merge
1d 6h
Merged PRs (30d)
5

Description

  • Used appropriate template for the issue type
  • Searched both open and closed issues for duplicates of this issue
  • Title adequately and concisely reflects the feature or the bug

Restify Version: master
Node.js Version: 16.17.0

Expected behaviour

prePath middleware should reduce path /// to /.

Actual behaviour

prePath middleware reduces /// to `` (empty string).

Repro case

Test case: https://github.com/restify/node-restify/compare/master...mridgway:node-restify:prePathEmptyString

Cause

This code will parse an empty string which returns null for pathname. The router will then assert the pathname as a string and throw.

Are you willing and able to fix this?

Yes, if/when I have some time.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked prePathEmptyString reproduction, then inspect lib/request.js around line 427 and the pathname assertion in lib/routerRegistryRadix.js around line 97. Confirm that the regression is covered and that prePath handling leaves /// as / rather than an empty pathname that causes the router to throw.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.