Skip to content

Commit

Permalink
Replace special characters in pkg name when checking npm_config env (#…
Browse files Browse the repository at this point in the history
…109)

Modify to substitute '_' for all special characters as well as '-'. Follow-up to #97.
  • Loading branch information
sanghyun-park authored and vweevers committed Sep 12, 2019
1 parent 652f169 commit 3c3cfee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/util-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ test('urlTemplate() returns different templates based on pkg and rc', function (
download: true
}
delete o7.binary
var envProperty = 'npm_config_' + o7.pkg.name.replace(/-/g, '_') + '_binary_host'
var envProperty = 'npm_config_' + o7.pkg.name.replace(/[^a-zA-Z0-9]/g, '_') + '_binary_host'
process.env[envProperty] = 'http://overriden-url.com/overriden-path'
var t7 = util.urlTemplate(o7)
delete process.env[envProperty]
Expand Down
2 changes: 1 addition & 1 deletion util.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function urlTemplate (opts) {
}

function getHostMirrorUrl (opts) {
var propName = 'npm_config_' + (opts.pkg.name || '').replace(/-/g, '_') + '_binary_host'
var propName = 'npm_config_' + (opts.pkg.name || '').replace(/[^a-zA-Z0-9]/g, '_') + '_binary_host'
return process.env[propName] || process.env[propName + '_mirror']
}

Expand Down

0 comments on commit 3c3cfee

Please sign in to comment.