Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

Commit db36c7a

Browse files
author
Marco
authored
Support URL-safe strings in scoped packages (#148)
1 parent b772a42 commit db36c7a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

test/util-test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,22 @@ test('getDownloadUrl() expands template to correct values', function (t) {
188188
}
189189
var url3 = util.getDownloadUrl(o3)
190190
t.equal(url3, url2, 'scope does not matter for download url')
191+
var o4 = {
192+
pkg: {
193+
name: '@scope-with.special~chars_/a-native-module',
194+
version: 'x.y.z+beta77',
195+
binary: {
196+
host: 'https://foo.com',
197+
module_name: 'a-native-module-bindings',
198+
package_name: '{name}-{package_name}-{version}-{major}-{minor}-{patch}-{build}-{abi}-{node_abi}-{platform}-{arch}-{configuration}-{module_name}'
199+
}
200+
},
201+
platform: 'coolplatform',
202+
arch: 'futureplatform',
203+
debug: true
204+
}
205+
var url4 = util.getDownloadUrl(o4)
206+
t.equal(url4, url2, 'scope with special characters does not matter for download url')
191207
t.end()
192208
})
193209

util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var crypto = require('crypto')
55
var expandTemplate = require('expand-template')()
66

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

0 commit comments

Comments
 (0)