mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 21:23:45 +00:00
fix(desktop): match cached APT releases for local URIs (#12222)
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
1 parent
50ed816a06
commit
c27f6fff84
2 files changed
+15
-2
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user