Skip to content

Commit 3bd4117

Browse files
authored
fix: allow some URL safe characters in the scoep regex (#38)
1 parent b4f16fd commit 3bd4117

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515

16-
const registryRegex = /(@[a-zA-Z0-9-]+:)?registry=https:(\/\/[a-zA-Z0-9-]+[-]npm[.]pkg[.]dev\/.*\/)/;
16+
const registryRegex = /(@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*:)?registry=https:(\/\/[a-zA-Z0-9-]+[-]npm[.]pkg[.]dev\/.*\/)/;
1717
const authTokenRegex = /(\/\/[a-zA-Z0-9-]+[-]npm[.]pkg[.]dev\/.*\/):_authToken=(.*)/;
1818
const passwordRegex = /(\/\/[a-zA-Z0-9-]+[-]npm[.]pkg[.]dev\/.*\/):_password=(.*)/;
1919

test/test.update.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,33 @@ describe('#update', () => {
225225
assert.equal(gotTo, `//us-west1-npm.pkg.dev/my-project/my-repo/:_authToken=abcd`);
226226
});
227227

228+
229+
it('add new scoped with dot', async function(){
230+
fromConfigPath = getConfigPath(`${this.test.title}-from`);
231+
toConfigPath = getConfigPath(`${this.test.title}-to`)
232+
fs.writeFileSync(fromConfigPath, `@my.scope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/`);
233+
fs.writeFileSync(toConfigPath, ``);
234+
await update.updateConfigFiles(fromConfigPath, toConfigPath, creds);
235+
236+
const gotFrom = fs.readFileSync(fromConfigPath, 'utf8');
237+
const gotTo = fs.readFileSync(toConfigPath, 'utf8');
238+
assert.equal(gotFrom, `@my.scope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/`);
239+
assert.equal(gotTo, `//us-west1-npm.pkg.dev/my-project/my-repo/:_authToken=abcd`);
240+
});
241+
242+
it('add new scoped starting with tilda', async function(){
243+
fromConfigPath = getConfigPath(`${this.test.title}-from`);
244+
toConfigPath = getConfigPath(`${this.test.title}-to`)
245+
fs.writeFileSync(fromConfigPath, `@~myscope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/`);
246+
fs.writeFileSync(toConfigPath, ``);
247+
await update.updateConfigFiles(fromConfigPath, toConfigPath, creds);
248+
249+
const gotFrom = fs.readFileSync(fromConfigPath, 'utf8');
250+
const gotTo = fs.readFileSync(toConfigPath, 'utf8');
251+
assert.equal(gotFrom, `@~myscope:registry=https://us-west1-npm.pkg.dev/my-project/my-repo/`);
252+
assert.equal(gotTo, `//us-west1-npm.pkg.dev/my-project/my-repo/:_authToken=abcd`);
253+
});
254+
228255
it('add new to config file does not exist', async function(){
229256
fromConfigPath = getConfigPath(`${this.test.title}-from`);
230257
toConfigPath = getConfigPath(`${this.test.title}-to`)

0 commit comments

Comments
 (0)