From 55b3d5d0b76d8ca3a774ec3771618eff2e74d7bc Mon Sep 17 00:00:00 2001 From: netptop Date: Wed, 18 Mar 2020 18:43:41 -0400 Subject: [PATCH] fixed google search issue. --- config.js | 7 ++++--- test/siteproxylocal.test.js | 19 +++++++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/config.js b/config.js index fe6a049..48b0c52 100644 --- a/config.js +++ b/config.js @@ -81,9 +81,6 @@ const pathReplace = ({host, httpType, body}) => { let myRe = new RegExp(`href=([\"\']?)/([-a-z0-9_]+?)`, 'g') body = body.replace(myRe, `href=$1/${httpType}/${host}/$2`) - myRe = new RegExp(` href=([\"\']?)([-a-z0-9_]+?)`, 'g') - body = body.replace(myRe, ` href=$1/${httpType}/${host}/$2`) - myRe = new RegExp(`href="/"`, 'g') body = body.replace(myRe, `href="/${httpType}/${host}/"`) @@ -199,8 +196,12 @@ const siteSpecificReplace = { 'src="[.]{2}/img/': `src="/https/www.mitbbs.com/img/`, }, 'web.telegram.org': { + ' href=([\"\']?)([-a-z0-9_]+?)': ` href=$1/https/web.telegram.org/$2`, ' src=([-a-z0-9_]+?)': ` src=/https/github.com/https/web.telegram.org/$1`, '(getJSON.")(js/locales/)': `$1/https/web.telegram.org/js/locales/`, + }, + 'doubibackup.com': { + ' href=([\"\']?)([-a-z0-9_]+?)': ` href=$1/https/doubibackup.com/$2`, } } diff --git a/test/siteproxylocal.test.js b/test/siteproxylocal.test.js index 773b857..85d40a7 100644 --- a/test/siteproxylocal.test.js +++ b/test/siteproxylocal.test.js @@ -262,7 +262,7 @@ test('doubi issue', async () => { url, }) // console.log(`${JSON.stringify(response.headers)}`) - // console.log(`${response.data}`) + console.log(`${response.data}`) expect(response.data.indexOf(`href="3x8ussyf.html"`)).toBe(-1) }, 15000); // should be done within 3 seconds. @@ -291,6 +291,21 @@ test('web.telegram.com href/src issues', async () => { url, }) // console.log(`${JSON.stringify(response.headers)}`) - console.log(`${response.data}`) + // console.log(`${response.data}`) expect(response.data.indexOf(`href=/https/github.com/https/web.telegram.org/e.value`)).toBe(-1) }, 15000); // should be done within 3 seconds. + + +test('web.telegram.com href/src issues', async () => { + const url = `${httpprefix}://${serverName}:${port}/https/www.google.com/search?ei=pJ5yXtfwHOPP0PEPwaGzqAk&q=%E7%BB%B4%E5%9F%BA%E7%99%BE%E7%A7%91` + const response = await axios({ + method: 'get', + headers: { + 'Accept': `text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9`, + }, + url, + }) + // console.log(`${JSON.stringify(response.headers)}`) + // console.log(`${response.data}`) + expect(response.data.indexOf(`/${httpprefix}://${serverName}:${port}/ht`)).toBe(-1) +}, 15000); // should be done within 3 seconds.