diff --git a/src/domain/desktop/aptRepositories.test.ts b/src/domain/desktop/aptRepositories.test.ts index c35503c094..8b9c9935f7 100644 --- a/src/domain/desktop/aptRepositories.test.ts +++ b/src/domain/desktop/aptRepositories.test.ts @@ -350,6 +350,14 @@ describe("apt index targets", () => { expect(aptListFileName(uri.href)).toBe("apt.example.com_a%5fb%7ec_"); }); + it.each([ + ["https://[2001:db8::1]:8443/apt/", "2001:db8::1:8443_apt_InRelease"], + ["https://[2001:db8::1]/apt/", "2001:db8::1_apt_InRelease"], + ["https://example.invalid/apt[1]/", "example.invalid_apt%5b1%5d_InRelease"], + ])("uses apt's release filename spelling for %s", (uri, filename) => { + expect(`${aptListFileName(uri)}InRelease`).toBe(filename); + }); + it("finds the sources entry of each target, by position and then URI and suite", () => { const [typora, k8s, noble] = targets; if (typora === undefined || k8s === undefined || noble === undefined) diff --git a/src/domain/desktop/aptRepositories.ts b/src/domain/desktop/aptRepositories.ts index 8b4ff04e53..9cb0ca8642 100644 --- a/src/domain/desktop/aptRepositories.ts +++ b/src/domain/desktop/aptRepositories.ts @@ -365,7 +365,9 @@ const QUOTED = new Set('\\|{}[]<>"^~_=!@#$%^&*'); export const aptListFileName = (uri: string): string => { const path = uri .replace(/^[a-z][a-z0-9+.-]*:\/\//iu, "") - .replace(/^[^/@]*@/u, ""); + .replace(/^[^/@]*@/u, "") + // APT removes authority brackets before encoding the path for the cache. + .replace(/^\[([0-9a-f.:]+)\](?=[:/]|$)/iu, "$1"); let quoted = ""; for (const character of path) { const code = character.codePointAt(0) ?? 0;