fix(remote_judger/luogu): cdn cc firewall
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2023-04-09 09:07:40 +08:00
parent bdd05d0527
commit 2c42382247
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -193,7 +193,20 @@ export default class LuoguProvider implements IBasicProvider {
} }
async safeGet(url: string) { async safeGet(url: string) {
const res = await this.get(url); const res = await this.get(url).ok(res => res.status < 400);
if ([302, 301].includes(res.status)) {
if (res.header['set-cookie']) {
Array.from(res.header['set-cookie']).forEach((cookie: string) => {
const name = cookie.split('=')[0];
const value = cookie.split('=')[1].split(';')[0];
this.setCookie(name, value);
});
}
return await this.get(url);
}
if (res.text.startsWith('<html><script>document.location.reload()')) { if (res.text.startsWith('<html><script>document.location.reload()')) {
const sec = this.getCookie.call( const sec = this.getCookie.call(