refactor: Download API

Now the download APIs are moved into a new file
This commit is contained in:
Peng-YM
2022-06-30 12:19:43 +08:00
parent 9653b09844
commit bb87a6c41e
14 changed files with 231 additions and 220 deletions

View File

@@ -0,0 +1,23 @@
export function getPlatformFromHeaders(headers) {
const keys = Object.keys(headers);
let UA = '';
for (let k of keys) {
if (/USER-AGENT/i.test(k)) {
UA = headers[k];
break;
}
}
if (UA.indexOf('Quantumult%20X') !== -1) {
return 'QX';
} else if (UA.indexOf('Surge') !== -1) {
return 'Surge';
} else if (UA.indexOf('Decar') !== -1 || UA.indexOf('Loon') !== -1) {
return 'Loon';
} else if (UA.indexOf('Shadowrocket') !== -1) {
return 'Clash';
} else if (UA.indexOf('Stash') !== -1) {
return 'Stash';
} else {
return 'JSON';
}
}