weird stuff

This commit is contained in:
Maikiwi 2022-10-16 19:51:48 -07:00
parent 6a67cd8a54
commit 4cb8cf5a19
3 changed files with 26 additions and 18 deletions

View file

@ -84,17 +84,20 @@ export class utils {
* @param url {string} URL param
* @param opts {object} Other options
*/
static fetch(url: string, opts = {}) {
static async fetch(url: string, opts = {}) {
Object.assign(opts, { headers: {
"User-Agent": utils.getWindow().webContents.getUserAgent()}
})
if (this.getStoreValue("advanced.experiments").includes("cider_mirror") === true) {
if (url.includes("api.github.com/")) {
return fetch(url.replace("api.github.com/", "mirror.api.cider.sh/v2/api/"), opts);
return await fetch(url.replace("api.github.com/", "mirror.api.cider.sh/v2/api/"), opts);
} else if (url.includes("raw.githubusercontent.com/")) {
return fetch(url.replace("raw.githubusercontent.com/", "mirror.api.cider.sh/v2/raw/"), opts);
return await fetch(url.replace("raw.githubusercontent.com/", "mirror.api.cider.sh/v2/raw/"), opts);
} else {
return fetch(url, opts);
return await fetch(url, opts);
}
} else {
return fetch(url, opts);
return await fetch(url, opts);
}
}
/**