From d94282069ccd5a64224aad7f1719144e601818ec Mon Sep 17 00:00:00 2001 From: Pin Lin Date: Sat, 4 Apr 2020 05:13:26 +0800 Subject: [PATCH] Add support for reurl.cc --- src/app.service.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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);