Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/server/src/sourceControl/giteaRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ it("accepts PR numbers and URLs only from the selected repository", () => {
giteaPullRequestNumber(`${base}/TEAM/REPO/pulls/42/files`, "team/repo", base),
42,
);
assert.strictEqual(
giteaPullRequestNumber(`${base}/%C3%A9quipe/r%C3%A9po/pulls/43/files`, "équipe/répo", base),
43,
);
for (const ref of [
"0",
"-1",
Expand Down
3 changes: 2 additions & 1 deletion apps/server/src/sourceControl/giteaRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export function giteaPullRequestNumber(
try {
const url = new URL(reference);
const base = new URL(baseUrl);
const expected = `${base.pathname.replace(/\/+$/u, "")}/${repository}/pulls/`;
const encodedRepository = repository.split("/").map(encodeURIComponent).join("/");
const expected = `${base.pathname.replace(/\/+$/u, "")}/${encodedRepository}/pulls/`;
if (
url.origin !== base.origin ||
!url.pathname.toLowerCase().startsWith(expected.toLowerCase())
Expand Down