diff --git a/src/domain/desktop/aptRepositories.test.ts b/src/domain/desktop/aptRepositories.test.ts index 8b9c9935f7..8fccd88f3e 100644 --- a/src/domain/desktop/aptRepositories.test.ts +++ b/src/domain/desktop/aptRepositories.test.ts @@ -351,8 +351,21 @@ describe("apt index targets", () => { }); it.each([ + ["file:/srv/apt/dists/stable/", "_srv_apt_dists_stable_InRelease"], + [ + "copy:/tmp/snapshot/dists/stable/", + "_tmp_snapshot_dists_stable_InRelease", + ], + [ + "file://machine/srv/apt/dists/stable/", + "machine_srv_apt_dists_stable_InRelease", + ], ["https://[2001:db8::1]:8443/apt/", "2001:db8::1:8443_apt_InRelease"], ["https://[2001:db8::1]/apt/", "2001:db8::1_apt_InRelease"], + [ + "https://[fe80::1%eth0]/apt/dists/stable/", + "fe80::1%25eth0_apt_dists_stable_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); diff --git a/src/domain/desktop/aptRepositories.ts b/src/domain/desktop/aptRepositories.ts index 9cb0ca8642..1fdc51c3f0 100644 --- a/src/domain/desktop/aptRepositories.ts +++ b/src/domain/desktop/aptRepositories.ts @@ -364,10 +364,10 @@ const QUOTED = new Set('\\|{}[]<>"^~_=!@#$%^&*'); /** apt's file name for a URI in its lists directory: no scheme or credentials, special characters quoted, `/` as `_`. */ export const aptListFileName = (uri: string): string => { const path = uri - .replace(/^[a-z][a-z0-9+.-]*:\/\//iu, "") + .replace(/^[a-z][a-z0-9+.-]*:(?:\/\/)?/iu, "") .replace(/^[^/@]*@/u, "") // APT removes authority brackets before encoding the path for the cache. - .replace(/^\[([0-9a-f.:]+)\](?=[:/]|$)/iu, "$1"); + .replace(/^\[([^\]]+)\](?=[:/]|$)/u, "$1"); let quoted = ""; for (const character of path) { const code = character.codePointAt(0) ?? 0;