From 0eb475152e0040c2623bfa76ec10053fa31059ac Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 25 Oct 2026 16:07:46 +0100 Subject: [PATCH] Registry: show who publishes a project, linked to their GitHub profile The index already carries each project's owners (the GitHub accounts the registry checked at submission), but neither the website nor the launcher showed them. The project page now says "Published by @login" with the avatar and a link to the profile; the launcher adds an @login link per owner. Only strings that are valid GitHub logins become links. Co-Authored-By: Claude Opus 5.5 --- launcher/src/browser/horizon.rs | 24 ++++++++++++++++++++++-- launcher/src/browser/horizon/tests.rs | 19 +++++++++++++++++++ website/src/mods.js | 15 ++++++++++++++- website/src/mods.test.mjs | 8 ++++++++ website/src/style.css | 3 +++ 5 files changed, 66 insertions(+), 3 deletions(-) diff --git a/launcher/src/browser/horizon.rs b/launcher/src/browser/horizon.rs index 501295c6b..e56f31e09 100644 --- a/launcher/src/browser/horizon.rs +++ b/launcher/src/browser/horizon.rs @@ -190,6 +190,18 @@ fn version_of(index: &Index, p: &index::Project, v: &index::Version) -> Version } } +/// A GitHub login as GitHub allows it (letters, digits, single dashes, at most 39), so an index +/// entry can't turn a link into something else. +fn github_login(login: &str) -> bool { + (1..=39).contains(&login.len()) + && login + .bytes() + .all(|b| b.is_ascii_alphanumeric() || b == b'-') + && !login.starts_with('-') + && !login.ends_with('-') + && !login.contains("--") +} + /// The words of a query found in a project's id, name, summary or authors. fn matches(p: &index::Project, text: &str) -> bool { let hay = format!("{} {} {} {}", p.id, p.name, p.summary, p.authors.join(" ")).to_lowercase(); @@ -277,9 +289,14 @@ impl Source for Registry { body.push_str(&format!("- {} {}{may}\n", m.name, w.version)); } } + // Who publishes it: the GitHub accounts the registry checked at submission. + let owners = p.owners.iter().filter(|o| github_login(o)).map(|o| Link { + label: format!("@{o}"), + url: format!("https://github.com/{o}"), + }); Ok(Details { body, - links: vec![ + links: [ Link { label: "Source".into(), url: p.source.clone(), @@ -292,7 +309,10 @@ impl Source for Registry { label: "Report".into(), url: format!("{REPORT}&title={}", p.id), }, - ], + ] + .into_iter() + .chain(owners) + .collect(), authors: p.authors.clone(), published: p .versions diff --git a/launcher/src/browser/horizon/tests.rs b/launcher/src/browser/horizon/tests.rs index bf98719d7..fb99462e1 100644 --- a/launcher/src/browser/horizon/tests.rs +++ b/launcher/src/browser/horizon/tests.rs @@ -143,3 +143,22 @@ fn registry_versions_run_when_made_for_this_game() { .collect(); assert_eq!(pick(Kind::Mod, &versions, false).unwrap().number, "0.1.0"); } + +#[test] +fn owner_links_only_take_github_logins() { + for ok in ["Stink-O", "ludovic111", "a"] { + assert!(github_login(ok), "{ok}"); + } + for bad in [ + "", + "-x", + "x-", + "a--b", + "bad login", + "a/b", + "x?y=1", + &"a".repeat(40), + ] { + assert!(!github_login(bad), "{bad}"); + } +} diff --git a/website/src/mods.js b/website/src/mods.js index 4819af374..acaee41f0 100644 --- a/website/src/mods.js +++ b/website/src/mods.js @@ -79,6 +79,19 @@ function installHtml(p, v) { `; } +// GitHub's rule for a login: letters, digits and single dashes, at most 39. +const LOGIN = /^(?!-)(?!.*--)[A-Za-z0-9-]{1,39}(? LOGIN.test(o)); + if (!owners.length) return ""; + const links = owners + .map((o) => `@${o}`) + .join(" "); + return `

Published by ${links}

`; +} + // One project's page. export function projectHtml(p) { const v = p.versions[0]; @@ -93,7 +106,7 @@ export function projectHtml(p) { .map((x) => `
  • ${escape(x.version)} ${escape(x.published || "")} · for ${escape(x.game)}${x.api ? ` · API ${escape(x.api)}` : ""}${x.changelog ? `
    ${markdown(x.changelog)}
    ` : ""}
  • `) .join(""); return `
    -
    ${icon(p)}

    ${escape(KIND_NAMES[p.kind] || p.kind)}${escape((p.authors || []).join(", "))}

    +
    ${icon(p)}

    ${escape(KIND_NAMES[p.kind] || p.kind)}${escape((p.authors || []).join(", "))}

    ${ownersHtml(p)}

    ${escape(p.name)}

    ${escape(p.summary || "")}

    ${trust(p)} ${escape(p.license)} ${escape(v.version)}${v.side ? ` ${escape(v.side)}` : ""}

    ${p.description ? `
    ${markdown(p.description)}
    ` : ""} diff --git a/website/src/mods.test.mjs b/website/src/mods.test.mjs index 75e3ca4c5..c5ff2e783 100644 --- a/website/src/mods.test.mjs +++ b/website/src/mods.test.mjs @@ -53,3 +53,11 @@ test("the submit form sends what the service reads", () => { assert.equal(entry.icon, undefined); assert.equal(JSON.parse(JSON.stringify(entry)).key, undefined, "an empty key isn't sent"); }); + +test("a project's page links its owners' GitHub profiles, and only valid logins", () => { + const html = projectHtml(project({ owners: ["Stink-O", "bad login", "-x", "a--b", "ok\">