Summary
@simple-libs/hosted-git-info@1.0.2 truncates SSH repository names that contain dots.
For example, git@github.com:davidsneighbour/kollitsch.dev.git is parsed as davidsneighbour/kollitsch instead of davidsneighbour/kollitsch.dev.
Reproduction
import { parseHostedGitUrl } from "@simple-libs/hosted-git-info";
const cases = [
"git@github.com:davidsneighbour/kollitsch.dev.git",
"git@github.com:davidsneighbour/kollitsch.dev",
"git@github.com:davidsneighbour/foo.bar.git",
"https://github.com/davidsneighbour/kollitsch.dev.git",
"https://github.com/davidsneighbour/kollitsch.dev",
];
for (const input of cases) {
console.log(input, parseHostedGitUrl(input));
}
Actual result
parseHostedGitUrl("git@github.com:davidsneighbour/kollitsch.dev.git")
// {
// url: "https://github.com/davidsneighbour/kollitsch",
// type: "github",
// host: "https://github.com",
// owner: "davidsneighbour",
// project: "kollitsch"
// }
parseHostedGitUrl("git@github.com:davidsneighbour/foo.bar.git")
// {
// url: "https://github.com/davidsneighbour/foo",
// type: "github",
// host: "https://github.com",
// owner: "davidsneighbour",
// project: "foo"
// }
Expected result
parseHostedGitUrl("git@github.com:davidsneighbour/kollitsch.dev.git")
// {
// url: "https://github.com/davidsneighbour/kollitsch.dev",
// type: "github",
// host: "https://github.com",
// owner: "davidsneighbour",
// project: "kollitsch.dev"
// }
parseHostedGitUrl("git@github.com:davidsneighbour/foo.bar.git")
// {
// url: "https://github.com/davidsneighbour/foo.bar",
// type: "github",
// host: "https://github.com",
// owner: "davidsneighbour",
// project: "foo.bar"
// }
Notes
This appears to come from the project capture groups excluding dots, for example ([^/.#]+). In the SSH URL branch, the expression also does not appear to be anchored to the end of the input, so .dev.git is effectively discarded.
HTTPS URLs keep the full path in url, but do not populate owner and project for dotted repository names:
parseHostedGitUrl("https://github.com/davidsneighbour/kollitsch.dev.git")
// {
// url: "https://github.com/davidsneighbour/kollitsch.dev",
// type: "github",
// host: "https://github.com"
// }
Downstream impact
This surfaced through @release-it/conventional-changelog, via conventional-changelog, when release notes were generated from a repository whose remote is:
git@github.com:davidsneighbour/kollitsch.dev.git
The generated changelog and GitHub release links pointed to:
https://github.com/davidsneighbour/kollitsch
instead of:
https://github.com/davidsneighbour/kollitsch.dev
Summary
@simple-libs/hosted-git-info@1.0.2truncates SSH repository names that contain dots.For example,
git@github.com:davidsneighbour/kollitsch.dev.gitis parsed asdavidsneighbour/kollitschinstead ofdavidsneighbour/kollitsch.dev.Reproduction
Actual result
Expected result
Notes
This appears to come from the project capture groups excluding dots, for example
([^/.#]+). In the SSH URL branch, the expression also does not appear to be anchored to the end of the input, so.dev.gitis effectively discarded.HTTPS URLs keep the full path in
url, but do not populateownerandprojectfor dotted repository names:Downstream impact
This surfaced through
@release-it/conventional-changelog, viaconventional-changelog, when release notes were generated from a repository whose remote is:The generated changelog and GitHub release links pointed to:
instead of: