diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 9259d40..6c52422 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "12.0.0" + ".": "12.0.1" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 195c3f9..f5e8c2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [12.0.1](https://github.com/npm/npm-package-arg/compare/v12.0.0...v12.0.1) (2024-12-10) +### Bug Fixes +* [`ea07a6e`](https://github.com/npm/npm-package-arg/commit/ea07a6edc71caae4db9342f90e03457edbb7bb24) [#197](https://github.com/npm/npm-package-arg/pull/197) allow for git usernames that start with a number (#197) (@wraithgar) +### Chores +* [`41aa799`](https://github.com/npm/npm-package-arg/commit/41aa799ee562f97d4bef48d0d08be8d4320bb219) [#196](https://github.com/npm/npm-package-arg/pull/196) bump @npmcli/template-oss from 4.23.3 to 4.23.4 (#196) (@dependabot[bot], @npm-cli-bot) + ## [12.0.0](https://github.com/npm/npm-package-arg/compare/v11.0.3...v12.0.0) (2024-09-25) ### ⚠️ BREAKING CHANGES * `npm-package-arg` now supports node `^18.17.0 || >=20.5.0` diff --git a/lib/npa.js b/lib/npa.js index 8094b3e..e926058 100644 --- a/lib/npa.js +++ b/lib/npa.js @@ -17,6 +17,7 @@ const hasSlashes = isWindows ? /\\|[/]/ : /[/]/ const isURL = /^(?:git[+])?[a-z]+:/i const isGit = /^[^@]+@[^:.]+\.[^:]+:.+$/i const isFilename = /[.](?:tgz|tar.gz|tar)$/i +const isPortNumber = /:[0-9]+(\/|$)/i function npa (arg, where) { let name @@ -324,7 +325,9 @@ function fromURL (res) { // git+ssh://git@my.custom.git.com:username/project.git#deadbeef // ...and various combinations. The username in the beginning is *required*. const matched = rawSpec.match(/^git\+ssh:\/\/([^:#]+:[^#]+(?:\.git)?)(?:#(.*))?$/i) - if (matched && !matched[1].match(/:[0-9]+\/?.*$/i)) { + // Filter out all-number "usernames" which are really port numbers + // They can either be :1234 :1234/ or :1234/path but not :12abc + if (matched && !matched[1].match(isPortNumber)) { res.type = 'git' setGitAttrs(res, matched[2]) res.fetchSpec = matched[1] diff --git a/package.json b/package.json index 80baa3d..ab285eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "npm-package-arg", - "version": "12.0.0", + "version": "12.0.1", "description": "Parse the things that can be arguments to `npm install`", "main": "./lib/npa.js", "directories": { @@ -18,7 +18,7 @@ }, "devDependencies": { "@npmcli/eslint-config": "^5.0.0", - "@npmcli/template-oss": "4.23.3", + "@npmcli/template-oss": "4.23.4", "tap": "^16.0.1" }, "scripts": { @@ -55,7 +55,7 @@ }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", - "version": "4.23.3", + "version": "4.23.4", "publish": true } } diff --git a/test/github.js b/test/github.js index f4fa1f0..bd3d2a4 100644 --- a/test/github.js +++ b/test/github.js @@ -89,12 +89,37 @@ require('tap').test('basic', function (t) { raw: 'foo@bar/foo', }, + 'git@github.com:12345': { + name: undefined, + type: 'git', + saveSpec: 'git+ssh://git@github.com:12345', + fetchSpec: 'ssh://git@github.com:12345', + raw: 'git@github.com:12345', + }, + + 'git@github.com:12345/': { + name: undefined, + type: 'git', + saveSpec: 'git+ssh://git@github.com:12345/', + fetchSpec: 'ssh://git@github.com:12345/', + raw: 'git@github.com:12345/', + }, + 'git@github.com:12345/foo': { name: undefined, type: 'git', saveSpec: 'git+ssh://git@github.com:12345/foo', + fetchSpec: 'ssh://git@github.com:12345/foo', raw: 'git@github.com:12345/foo', }, + + 'git@github.com:12345foo': { + name: undefined, + type: 'git', + saveSpec: 'git+ssh://git@github.com:12345foo', + fetchSpec: 'git@github.com:12345foo', + raw: 'git@github.com:12345foo', + }, } Object.keys(tests).forEach(function (arg) {