Skip to content

Commit

Permalink
Fix manNumberRegex in help.js
Browse files Browse the repository at this point in the history
The current regex will match any .[0-9]. pattern anywhere in the path, which will give incorrect results if npm is installed to a path like .../node-v14.5.5/...

This change restricts it to only the last path element.
  • Loading branch information
dmchurch committed Mar 24, 2021
1 parent 8ff0126 commit c546250
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/help.js
Expand Up @@ -9,7 +9,7 @@ const BaseCommand = require('./base-command.js')
// Strips out the number from foo.7 or foo.7. or foo.7.tgz
// We don't currently compress our man pages but if we ever did this would
// seemlessly continue supporting it
const manNumberRegex = /\.(\d+)(\..*)?$/
const manNumberRegex = /\.(\d+)(\.[^/\\]*)?$/

class Help extends BaseCommand {
/* istanbul ignore next - see test/lib/load-all-commands.js */
Expand Down

0 comments on commit c546250

Please sign in to comment.