-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (29 loc) · 986 Bytes
/
Copy pathindex.js
File metadata and controls
36 lines (29 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const code = 302;
const index =
"https://mackie100projects.altervista.org/download-opencore-configurator/";
const base =
"https://mackie100projects.altervista.org/download/opencore-configurator-";
const log = "https://mackie100projects.altervista.org/occ-changelog-version-";
addEventListener("fetch", (event) => {
event.respondWith(handleRequest(event.request));
});
async function handleRequest(request) {
const url = new URL(request.url);
const { pathname, searchParams } = url;
let path = pathname.split("/")[1];
// console.log(pathname)
if (path) {
const v = path.split(".");
if (v.length !== 4) {
return Response.redirect(index, code);
}
path = path.replaceAll(".", "-");
const queryLog = searchParams.has("log");
// console.log(queryLog)
if (queryLog) {
return Response.redirect(log + path + "/", code);
}
return Response.redirect(base + path + "/", code);
}
return Response.redirect(index, code);
}