Dough Git

commit

aaa

commit
b92f23865c150b0724e6f771fc99429e0f505aa8
author
Clove Twilight <[email protected]>
date
2026-09-04 00:27

diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..26f4214
Binary files /dev/null and b/.DS_Store differ
diff --git a/src/server.ts b/src/server.ts
index 9e15b60..bc7edb7 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -975,9 +975,9 @@ app.post("/:owner/:name/mirrors", async (c) => {
       view.messagePage({
         title: "that isn't a mirror URL",
         message:
-          `The ${rejected.join(" and ")} link was refused. A mirror must be an ` +
-          `https URL of the form https://${mirrorHost(rejected[0] as MirrorKind)}/owner/repo ` +
-          `— no other host, no credentials, no port.`,
+          `The ${rejected.join(" and ")} link was refused. Give the repository as ` +
+          `owner/repo — for example doughmination/dough-git — and it is looked up on ` +
+          `${mirrorHost(rejected[0] as MirrorKind)}.`,
         user: c.get("user"),
       }),
       400,
diff --git a/src/styles/app.css.ts b/src/styles/app.css.ts
index 829f827..79032b9 100644
--- a/src/styles/app.css.ts
+++ b/src/styles/app.css.ts
@@ -131,7 +131,9 @@ export const classes = {
   }),
 
   profileName: style({
-    fontSize: "1.4rem",
+    fontFamily: vars.display,
+    fontSize: "1.6rem",
+    letterSpacing: "0.01em",
     margin: 0,
   }),
 
@@ -340,8 +342,10 @@ globalStyle(`${readme} > :last-child`, { marginBottom: 0 });
 globalStyle(
   `${readme} h1, ${readme} h2, ${readme} h3, ${readme} h4, ${readme} h5, ${readme} h6`,
   {
+    fontFamily: vars.display,
     fontWeight: 600,
     lineHeight: 1.25,
+    letterSpacing: "0.01em",
     margin: "1.5rem 0 0.75rem",
   },
 );
diff --git a/src/styles/fonts.css.ts b/src/styles/fonts.css.ts
index 906a3b1..772f008 100644
--- a/src/styles/fonts.css.ts
+++ b/src/styles/fonts.css.ts
@@ -15,9 +15,16 @@ const COMIC_CODE = [
   { file: "ComicCode-Bold", weight: 700, style: "normal" },
 ] as const;
 
+globalFontFace("Ink Free", {
+  src: `url('${CDN}/Ink-Free/Inkfree.woff2') format('woff2')`,
+  fontWeight: 400,
+  fontStyle: "normal",
+  fontDisplay: "swap",
+});
+
 for (const { file, weight, style } of COMIC_CODE) {
   globalFontFace("Comic Code", {
-    src: `url('${CDN}/Comic-Code/woff2/${file}.woff2') format('woff2'), url('${CDN}/Comic-Code/woff/${file}.woff') format('woff')`,
+    src: `url('${CDN}/Comic-Code/woff2/${file}.woff2') format('woff2')`,
     fontWeight: weight,
     fontStyle: style,
     fontDisplay: "swap",
diff --git a/src/styles/theme.css.ts b/src/styles/theme.css.ts
index 2b583e3..9f131bc 100644
--- a/src/styles/theme.css.ts
+++ b/src/styles/theme.css.ts
@@ -28,6 +28,7 @@ export const vars = createGlobalThemeContract({
   text: "text",
 
   font: "font",
+  display: "display",
   mono: "mono",
   radius: "radius",
 });
@@ -52,6 +53,7 @@ createGlobalTheme(":root", vars, {
   text: "#f4f6fb",
 
   font: "'Comic Code', system-ui, -apple-system, sans-serif",
+  display: "'Ink Free', 'Comic Code', system-ui, -apple-system, sans-serif",
   mono: "ui-monospace, SFMono-Regular, Menlo, monospace",
   radius: "0",
 });
diff --git a/src/urls.ts b/src/urls.ts
index 8921130..635544e 100644
--- a/src/urls.ts
+++ b/src/urls.ts
@@ -58,24 +58,41 @@ export function mirrorHost(kind: MirrorKind): string {
   return MIRROR_HOSTS[kind];
 }
 
-const PATH_SEGMENT = /^[A-Za-z0-9._-]+$/;
+const PATH_SEGMENT = /^[A-Za-z0-9._-]{1,100}$/;
 
 function safePathSegment(s: string): boolean {
-  return PATH_SEGMENT.test(s) && !s.startsWith(".") && !s.includes("..");
+  if (!PATH_SEGMENT.test(s) || s.startsWith("-")) return false;
+  return s !== "." && s !== ".." && !s.includes("..");
 }
 
-export function mirrorUrl(kind: MirrorKind, raw: string): string | null {
-  const url = parseStrict(raw, [MIRROR_HOSTS[kind]]);
-  if (!url) return null;
+export function mirrorPath(kind: MirrorKind, raw: string): string | null {
+  const value = raw.trim();
+  if (!value || value.length > MAX_URL) return null;
+  if (HOSTILE.test(value)) return null;
+
+  const prefix = `https://${MIRROR_HOSTS[kind]}/`;
+  const bare = (
+    value.toLowerCase().startsWith(prefix) ? value.slice(prefix.length) : value
+  ).replace(/\/+$/, "");
 
-  const parts = url.pathname.split("/").filter((p) => p.length > 0);
+  const parts = bare.split("/");
   if (parts.length !== 2) return null;
 
   const owner = parts[0]!;
   const repo = parts[1]!.replace(/\.git$/, "");
   if (!safePathSegment(owner) || !safePathSegment(repo)) return null;
 
-  return `https://${url.hostname}/${owner}/${repo}`;
+  return `${owner}/${repo}`;
+}
+
+export function mirrorUrl(kind: MirrorKind, raw: string): string | null {
+  const path = mirrorPath(kind, raw);
+  return path === null ? null : `https://${MIRROR_HOSTS[kind]}/${path}`;
+}
+
+export function mirrorSlug(kind: MirrorKind, url: string): string {
+  const prefix = `https://${MIRROR_HOSTS[kind]}/`;
+  return url.startsWith(prefix) ? url.slice(prefix.length) : url;
 }
 
 const DISCORD_HOSTS = [
diff --git a/src/views.ts b/src/views.ts
index ae6596e..eb89b66 100644
--- a/src/views.ts
+++ b/src/views.ts
@@ -7,7 +7,7 @@ import { classes as c } from "./styles/index.ts";
 import { icon } from "./icons.ts";
 import { escapeHtml, renderMarkdown, plainSummary } from "./markdown.ts";
 import { sessionSlug } from "./auth.ts";
-import { maskWebhook, mirrorHost, MIRROR_KINDS, type MirrorKind } from "./urls.ts";
+import { maskWebhook, mirrorHost, mirrorSlug, MIRROR_KINDS, type MirrorKind } from "./urls.ts";
 import type { SessionUser } from "./auth.ts";
 import type { CollaboratorRow } from "./access.ts";
 import type { TokenRow } from "./tokens.ts";
@@ -497,7 +497,7 @@ function mirrorSection(
       const status = statuses.get(link.kind) ?? null;
       const view = describeMirror(link, status, nowSec);
       return `      <div class="${c.mirrorRow}">
-        <span class="${c.mirrorKind}"><a class="${c.withIcon}" href="${esc(link.url)}" rel="nofollow noopener noreferrer">${icon(link.kind === "github" ? "github" : "git-branch")}${esc(link.kind)}</a></span>
+        <span class="${c.mirrorKind}"><a class="${c.withIcon}" href="${esc(link.url)}" rel="nofollow noopener noreferrer" title="${esc(link.kind)}">${icon(link.kind === "github" ? "github" : "git-branch")}${esc(mirrorSlug(link.kind, link.url))}</a></span>
         <span class="${view.cls} ${c.withIcon}">${icon(view.glyph)}${esc(view.label)}</span>
         <span class="${c.commitHash}">${esc(view.sha)}</span>
         <span class="${c.repoDesc}">${esc(view.detail)}</span>
@@ -534,8 +534,9 @@ ${checkButton}
     const existing = links.find((l) => l.kind === kind);
     return `      <div class="${c.formRow}">
         <label class="${c.cloneLabel} ${c.withIcon}" for="mirror-${kind}">${icon(kind === "github" ? "github" : "git-branch")}${kind}</label>
-        <input id="mirror-${kind}" class="${c.grow}" type="url" name="${kind}"
-          value="${esc(existing?.url ?? "")}" placeholder="https://${esc(mirrorHost(kind))}/user/repo">
+        <input id="mirror-${kind}" class="${c.grow}" type="text" name="${kind}"
+          value="${esc(existing ? mirrorSlug(kind, existing.url) : "")}"
+          placeholder="user/repo" pattern="[^\\s/]+/[^\\s/]+/?" autocapitalize="off" spellcheck="false">
         <label><input type="checkbox" name="${kind}_private"${existing?.isPrivate ? " checked" : ""}> private</label>
       </div>`;
   };
@@ -543,7 +544,7 @@ ${checkButton}
   const form = isOwner
     ? `    <form method="post" action="${base(owner, name)}/mirrors" class="${c.cloneBox}">
 ${MIRROR_KINDS.map(field).join("\n")}
-      <p class="${c.repoDesc}">Only ${esc(MIRROR_KINDS.map(mirrorHost).join(" and "))} are accepted.
+      <p class="${c.repoDesc}">Give the <code>user/repo</code> on ${esc(MIRROR_KINDS.map(mirrorHost).join(" or "))} &mdash; not a full URL.
       Mark a mirror <em>private</em> to skip status checks — they are anonymous, so a private
       mirror would otherwise always look unreachable. Clear a field to remove it.</p>
       <button type="submit">${icon("save")}save mirrors</button>
diff --git a/test/urls.test.mjs b/test/urls.test.mjs
index b1baf26..7a7ce73 100644
--- a/test/urls.test.mjs
+++ b/test/urls.test.mjs
@@ -4,6 +4,8 @@
 
 import {
   mirrorUrl,
+  mirrorPath,
+  mirrorSlug,
   discordWebhookUrl,
   maskWebhook,
   isMirrorKind,
@@ -27,6 +29,43 @@ check("codeberg is a kind", isMirrorKind("codeberg"));
 check("gitlab is not", !isMirrorKind("gitlab"));
 check("only two kinds exist", MIRROR_KINDS.length === 2);
 
+console.log("\n-- mirrors are given as user/repo --");
+ok("github", "user/repo", "https://github.com/user/repo");
+ok("codeberg", "user/repo", "https://codeberg.org/user/repo");
+ok("github", "Clove-Web/dough-git", "https://github.com/Clove-Web/dough-git");
+ok("github", "user/repo.git", "https://github.com/user/repo");
+ok("github", "  user/repo  ", "https://github.com/user/repo");
+ok("github", "user/repo/", "https://github.com/user/repo");
+ok("codeberg", "My-User/my.repo_1", "https://codeberg.org/My-User/my.repo_1");
+
+check("the path form is normalised", mirrorPath("github", " user/repo.git ") === "user/repo");
+check("a slug round-trips for display", mirrorSlug("github", mirrorUrl("github", "a/b")) === "a/b");
+check("a foreign url is left alone by the slug", mirrorSlug("github", "https://x.test/a/b") === "https://x.test/a/b");
+
+console.log("\n-- profile repositories may start with a dot --");
+ok("codeberg", "Clove-Web/.profile", "https://codeberg.org/Clove-Web/.profile");
+ok("github", "Clove-Web/.github", "https://github.com/Clove-Web/.github");
+ok("github", ".owner/.repo", "https://github.com/.owner/.repo");
+no("github", "user/.", "a bare dot repo");
+no("github", "user/..", "a bare double dot repo");
+no("github", "user/..hidden", "a double dot inside a name");
+no("github", "../repo", "traversal in the owner");
+
+console.log("\n-- user/repo is two segments, nothing else --");
+no("github", "repo", "one segment");
+no("github", "a/b/c", "three segments");
+no("github", "/user/repo", "a leading slash");
+no("github", "github.com/user/repo", "a host without a scheme");
+no("github", "http://github.com/user/repo", "a plain-http url");
+no("github", "https://github.com//user/repo", "a doubled slash");
+no("github", "-u/repo", "a leading dash owner");
+no("github", "user/-o", "a leading dash repo");
+no("github", "user/re po", "an inner space");
+no("github", "user/repo?x=1", "a query string");
+no("github", "user/repo#f", "a fragment");
+no("github", "user@host/repo", "an at sign");
+no("github", `${"a".repeat(101)}/repo`, "an over-long owner");
+
 console.log("\n-- valid mirror URLs --");
 ok("github", "https://github.com/user/repo", "https://github.com/user/repo");
 ok("codeberg", "https://codeberg.org/user/repo", "https://codeberg.org/user/repo");
@@ -86,7 +125,7 @@ no("github", "https://github.com/user/repo/../../admin", "traversal in path");
 no("github", "https://github.com/../etc/passwd", "traversal as owner");
 no("github", "https://github.com/./repo", "dot segment");
 no("github", "https://github.com/user/..", "dotdot repo");
-no("github", "https://github.com/user/.hidden", "leading-dot repo");
+ok("github", "https://github.com/user/.hidden", "https://github.com/user/.hidden");
 no("github", "https://github.com/us er/repo", "whitespace in path");
 no("github", "https://github.com/user/re%2Fpo", "encoded slash");