fix(desktop): match cached APT releases for IPv6 hosts (#12240)

This commit is contained in:
ShuaixinHuang authored and GitHub committed 2026-11-19 06:14:30 -05:00
1 parent 51e48b8a28
commit 7eb8f7506f
2 files changed
+11 -1

No files matched your search

@@ -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)
+3 -1
View File
@@ -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;