fix(ui): keep http and upper-case https skill sources clickable on the detail page

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
ryan 2026-09-16 18:45:11 +00:00
parent 7cd6869cfa
commit 2bb478fb59
2 changed files with 11 additions and 1 deletions

View file

@ -157,6 +157,15 @@ describe("getSourceLink", () => {
expect(getSourceLink({ source: "github" })).toBeNull();
});
it("keeps http and upper-case https urls registered through the api clickable", () => {
expect(getSourceLink({ source: "url", url: "http://git.internal.example/org/repo" })).toBe(
"http://git.internal.example/org/repo",
);
expect(getSourceLink({ source: "git-subdir", url: "HTTPS://gitlab.com/org/repo", path: "sub/dir" })).toBe(
"HTTPS://gitlab.com/org/repo",
);
});
it("returns null for an ssh clone url, which is not browsable", () => {
expect(getSourceLink({ source: "url", url: "git@ghe.example.com:org/repo.git" })).toBeNull();
expect(getSourceLink({ source: "url", url: "ssh://git@ghe.example.com/org/repo.git" })).toBeNull();

View file

@ -37,6 +37,7 @@ const IPV4_HOST_REGEX = /^\d{1,3}(\.\d{1,3}){3}$/;
const GITHUB_ORG_REGEX = /^[A-Za-z0-9-]+$/;
const GITHUB_REPO_REGEX = /^[A-Za-z0-9._-]+$/;
const BROWSABLE_URL_REGEX = /^https?:\/\//i;
const SSH_SCHEME = "ssh://";
const SSH_SCP_REGEX = /^([a-z0-9._-]+)@([^:/@]+):(?!\/)(.+)$/i;
@ -316,7 +317,7 @@ export const getSourceLink = (source: PluginSource): string | null => {
return `https://github.com/${source.repo}`;
}
const linksToUrl = source.source === "url" || source.source === "git-subdir" || source.source === "archive";
return linksToUrl && source.url?.startsWith("https://") ? source.url : null;
return linksToUrl && source.url && BROWSABLE_URL_REGEX.test(source.url) ? source.url : null;
};
/**