Add support for reurl.cc

This commit is contained in:
2020-04-04 05:13:26 +08:00
parent b8af5452c3
commit d94282069c

View File

@ -1,10 +1,11 @@
import axios from 'axios';
import cheerio from 'cheerio';
const fetchTarget = async (target: string) => {
return await axios.get(target, {
maxRedirects: 0,
validateStatus: (status) => {
return status >= 300 && status < 400;
return status >= 200 && status < 400;
},
});
};
@ -16,6 +17,12 @@ export const getLocationOfTarget = async (target: string) => {
if (response.headers.location) {
return response.headers.location as string;
}
// for reurl.cc
if (target.includes('reurl.cc')) {
const $ = cheerio.load(response.data);
return $('#url').attr('value');
}
}
catch (err) {
console.log(err);