You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Detect GitHub and GitLab SSH repository URLs when rewriting README links - #1362
When package.json uses an SSH repository URL, such as "repository": { "type": "git", "url": "[email protected]:owner/repo.git" }, vsce package doesn't recognize the repository as GitHub. If the README has a relative image like , packaging fails with "Couldn't detect the repository where this extension is published. The image 'images/demo.gif' will be broken in README.md. GitHub/GitLab repositories will be automatically detected...", even though the repository is on GitHub. Without relative links, #123 issue references are not turned into links. GitLab URLs like [email protected]:group/project.git have the same problem. The cause is guessBaseUrls: its regexes only accept github.com/ or github: (and the same for GitLab), so they miss the github.com: separator. The Marketplace links in the same package already handle this URL form correctly, because ManifestProcessor reads it with hosted-git-info, and isGitHubRepository also expects [email protected]:.
This PR lets the GitHub and GitLab regexes in guessBaseUrls also accept .com:, so SSH URLs get the same https://github.com/owner/repo/blob/HEAD (or GitLab) base URLs as HTTPS URLs. The port of a URL with a scheme, as in ssh://[email protected]:22/owner/repo.git, is dropped before matching instead of being read as the owner, while a numeric namespace in an SCP-like URL, as in [email protected]:123/group/project.git, is kept. Hosts that only end with github or gitlab, like [email protected]:owner/repo.git, are not taken for GitHub or GitLab.
How to test
Command
Result
npx mocha --grep "ssh format"
3 passing; the new tests "should infer baseContentUrl if its a github repo (ssh format)", "should infer baseContentUrl if its a gitlab repo (ssh format)" and "should infer baseContentUrl if its a gitlab repo with a numeric namespace (ssh format)" fail without the change
npx mocha --grep "host that only ends"
1 passing; the new test "should not replace issue links with urls if its an ssh url of a host that only ends with github or gitlab" fails without the host check
npm test
409 passing, 5 pending; 4 collect tests fail before and after the change only because yarn is not installed on this machine
When `package.json` uses an SSH repository URL, such as `"repository": { "type": "git", "url": "[email protected]:owner/repo.git" }`, `vsce package` doesn't recognize the repository as GitHub. If the README has a relative image like ``, packaging fails with "Couldn't detect the repository where this extension is published. The image 'images/demo.gif' will be broken in README.md. GitHub/GitLab repositories will be automatically detected...", even though the repository is on GitHub. Without relative links, `#123` issue references are not turned into links. GitLab URLs like `[email protected]:group/project.git` have the same problem. The cause is `guessBaseUrls`: its regexes only accept `github.com/` or `github:` (and the same for GitLab), so they miss the `github.com:` separator. The Marketplace links in the same package already handle this URL form correctly, because `ManifestProcessor` reads it with `hosted-git-info`, and `isGitHubRepository` also expects `[email protected]:`.
Co-authored-by: Copilot <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Scheme-based GitHub and GitLab URLs with explicit ports are parsed as incorrect repository paths, silently rewriting Markdown and issue links to the wrong repository.
Adds support for SCP-style SSH repository URLs in vsce’s Markdown processing, enabling automatic GitHub and GitLab URL inference for relative links, images, and issue references.
Changes:
Extends repository detection to accept github.com: and gitlab.com: separators.
Adds README regression tests for both providers’ SSH URL formats.
File
Description
src/test/package.test.ts
Adds SSH repository URL tests for GitHub and GitLab.
src/package.ts
Extends repository-matching expressions to recognize SCP-style SSH URLs.
`ssh://[email protected]:22/owner/repo.git` matched `github.com:` and gave the project `22/owner`. Allow a port before the path, and test both URL forms for GitHub and GitLab.
Co-authored-by: Copilot <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The regex misinterprets a numeric namespace in SCP-style GitLab URLs as a port, causing README, changelog, and issue links to target the wrong project.
`[email protected]:123/subgroup/project.git` matched `gitlab.com:123/` as a host with a port and gave the project `subgroup/project`. Drop the port only from URLs with a scheme, before matching, and test a numeric namespace in both URL forms.
Co-authored-by: Copilot <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Unanchored repository patterns misclassify SSH hosts such as mygithub.com and mygitlab.com, silently rewriting documentation links and issue references to the wrong hosts.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Anchor GitHub and GitLab hostname matches
src/package.ts:985
The unanchored patterns now accept [email protected]:owner/repo.git and [email protected]:group/project.git as public GitHub/GitLab repositories. This silently rewrites relative README/changelog links and issue references to the wrong hosts. Match the complete hostname in both patterns, preserve the supported URL and shorthand forms, and add negative SSH-host regression tests.
With the SSH form, `[email protected]:owner/repo.git` and `[email protected]:group/project.git` were taken for GitHub and GitLab repositories, so README links and issue references pointed to the wrong host. Require that `github`/`gitlab` isn't preceded by a letter, digit, `_` or `-`, and test both hosts.
Co-authored-by: Copilot <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because provider-host matching can misidentify dotted mirror domains and rewrite README/changelog links and issue references to the wrong host.
No open issues 🎉
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
package.jsonuses an SSH repository URL, such as"repository": { "type": "git", "url": "[email protected]:owner/repo.git" },vsce packagedoesn't recognize the repository as GitHub. If the README has a relative image like, packaging fails with "Couldn't detect the repository where this extension is published. The image 'images/demo.gif' will be broken in README.md. GitHub/GitLab repositories will be automatically detected...", even though the repository is on GitHub. Without relative links,#123issue references are not turned into links. GitLab URLs like[email protected]:group/project.githave the same problem. The cause isguessBaseUrls: its regexes only acceptgithub.com/orgithub:(and the same for GitLab), so they miss thegithub.com:separator. The Marketplace links in the same package already handle this URL form correctly, becauseManifestProcessorreads it withhosted-git-info, andisGitHubRepositoryalso expects[email protected]:.This PR lets the GitHub and GitLab regexes in
guessBaseUrlsalso accept.com:, so SSH URLs get the samehttps://github.com/owner/repo/blob/HEAD(or GitLab) base URLs as HTTPS URLs. The port of a URL with a scheme, as inssh://[email protected]:22/owner/repo.git, is dropped before matching instead of being read as the owner, while a numeric namespace in an SCP-like URL, as in[email protected]:123/group/project.git, is kept. Hosts that only end withgithuborgitlab, like[email protected]:owner/repo.git, are not taken for GitHub or GitLab.How to test
npx mocha --grep "ssh format"npx mocha --grep "host that only ends"npm testcollecttests fail before and after the change only becauseyarnis not installed on this machinenpx tsc --noEmit --typeRoots ./node_modules/@types