Relative links in a bounty description all resolve to github.com/MergeFi/frontend, whatever repository the issue came from (incomplete fix for #651)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 82/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- next.js, react, typescript
Direzione di ricerca
Inizia da src/components/bounty/BountyDescription.tsx e dalla chiamata a BountyDescription in src/app/issues/[id]/page.tsx; segui il percorso del contesto del repository del bounty fino alla risoluzione dei link. Aggiungi o aggiorna BountyDescription.test.tsx per ./, ../, / e i link relativi semplici, usando un repository diverso da MergeFi/frontend. Il lavoro è concluso quando questi link vengono risolti nel repository e nella ref corretti, mentre i link assoluti e le ancore restano invariati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Location
src/components/bounty/BountyDescription.tsx:9-23 — the REPO_BASE_URL constant and resolveRepoUrl(), used by the a override at :33-42.
Problem
const REPO_BASE_URL = "https://github.com/MergeFi/frontend";
function resolveRepoUrl(href: string | undefined): string | undefined {
if (!href) return href;
if (/^[a-z][a-z0-9+.-]*:/i.test(href)) return href;
if (href.startsWith("#")) return href;
if (href.startsWith("./") || href.startsWith("../") || href.startsWith("/")) {
return `${REPO_BASE_URL}/${href.replace(/^\.\//, "")}`;
}
return `${REPO_BASE_URL}/${href}`;
}
The base URL is a hardcoded constant pointing at MergeFi's own frontend repository. But the markdown being rendered is an arbitrary third party's GitHub issue body: src/app/issues/[id]/page.tsx:123 calls <BountyDescription description={bounty.description} />, and a Bounty can come from any org/repo on the platform. So a relative link in, say, stellar/soroban-examples' issue body is rewritten to https://github.com/MergeFi/frontend/CONTRIBUTING.md — a URL in an unrelated repository, which almost always 404s and, when it does not, points the reader at the wrong project's file.
Closed issue #651 reported that relative links "resolve against MergeFi instead of the repository". This fix changed which MergeFi URL they resolve against; it did not make them resolve against the repository. The component does not receive org or repo at all, so it has no way to build the right base.
Three further defects in the same function:
- Double slash on root-relative links.
href = "/docs/x.md"takes the third branch, which strips only a leading./, producinghttps://github.com/MergeFi/frontend//docs/x.md. - No
blob/treepath segment. GitHub does not serve repository files athttps://github.com/<org>/<repo>/<path>; a file link needs/blob/<ref>/<path>and a directory needs/tree/<ref>/<path>. Even with the correct org/repo,.../CONTRIBUTING.mdresolves to a non-existent page rather than the file. ../is not normalised.href = "../../README.md"is concatenated literally, givinghttps://github.com/MergeFi/frontend/../../README.md.
The docblock at :4-8 also still describes the pre-fix behaviour ("resolve against the MergeFi/frontend repo instead of the site origin") as the bug, which reads as if the current constant were the fix.
Why it matters
GitHub issue bodies lean on relative links constantly — see ./docs/architecture.md, follow ../CONTRIBUTING.md, as in /src/lib/escrow.rs. A contributor reading a bounty on MergeFi clicks one of these to understand the task and lands on a 404 inside MergeFi's own frontend repository, with no indication that the link was rewritten. For a platform whose whole value is routing contributors to work they can do, silently misdirecting the links that explain the work is a direct obstacle; and pointing outside visitors at MergeFi's repo for another project's docs is actively confusing.
Reproduction
- Create or mock a bounty whose
org/repois notMergeFi/frontend— for examplestellar/soroban-examples— with a description containing:See ./docs/setup.md, ../CONTRIBUTING.md and /src/lib.rs for context. - Open
/issues/<that bounty id>. - Inspect the three rendered links. Their
hrefs are:https://github.com/MergeFi/frontend/docs/setup.mdhttps://github.com/MergeFi/frontend/../CONTRIBUTING.mdhttps://github.com/MergeFi/frontend//src/lib.rs
- Click any of them: GitHub returns 404, in the wrong repository.
Suggested fix
- Give
BountyDescriptionthe context it needs — add requiredorgandrepoprops (and an optionaldefaultBranch, falling back toHEAD), and passbounty.org/bounty.repofromsrc/app/issues/[id]/page.tsx:123. - Build the base per render as
https://github.com/${org}/${repo}and resolve the href with theURLconstructor against.../blob/${ref}/so../and/-prefixed paths are normalised by the platform instead of by string concatenation. Keep the existing early returns for absolute URLs and anchors. - Treat a root-relative
/pathas repo-root-relative (/blob/<ref>/path), which is what GitHub's own markdown renderer does inside an issue body. - Update the docblock at
:4-8to describe the new behaviour, and add tests inBountyDescription.test.tsxfor./,../,/and bare relative hrefs, asserting the generated URL for a non-MergeFi org/repo.
- Lingua principale
- TypeScript
- Stelle
- 1
- Fork
- 94
- Merge medio
- 1h 2m
- PR unite (30g)
- 25
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MergeFi/frontend
-
bug testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
accessibility bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MergeFi/frontend#835 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
accessibility bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di MergeFi/frontend
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
zapcooking/frontend#946 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
WiliamRosa/cosmos-semantic-platform#40 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
liberation-data/drivine#733 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
makecindy/cindy#10062 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno