Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Support URL-safe strings in scoped packages #148

Merged
merged 2 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/util-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ test('getDownloadUrl() expands template to correct values', function (t) {
}
var url3 = util.getDownloadUrl(o3)
t.equal(url3, url2, 'scope does not matter for download url')
var o4 = {
pkg: {
name: '@scope-with.special~chars_/a-native-module',
version: 'x.y.z+beta77',
binary: {
host: 'https://foo.com',
module_name: 'a-native-module-bindings',
package_name: '{name}-{package_name}-{version}-{major}-{minor}-{patch}-{build}-{abi}-{node_abi}-{platform}-{arch}-{configuration}-{module_name}'
}
},
platform: 'coolplatform',
arch: 'futureplatform',
debug: true
}
var url4 = util.getDownloadUrl(o4)
t.equal(url4, url2, 'scope with special characters does not matter for download url')
t.end()
})

Expand Down
2 changes: 1 addition & 1 deletion util.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var crypto = require('crypto')
var expandTemplate = require('expand-template')()

function getDownloadUrl (opts) {
var pkgName = opts.pkg.name.replace(/^@\w+\//, '')
var pkgName = opts.pkg.name.replace(/^@[a-zA-Z0-9_\-.~]+\//, '')
return expandTemplate(urlTemplate(opts), {
name: pkgName,
package_name: pkgName,
Expand Down