diff --git a/src/app.service.ts b/src/app.service.ts index 3f3c895..2ad3858 100644 --- a/src/app.service.ts +++ b/src/app.service.ts @@ -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);