Skip to content

Commit

Permalink
fixed google search issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
netptop committed Mar 18, 2020
1 parent 3725627 commit 55b3d5d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
7 changes: 4 additions & 3 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}/"`)

Expand Down Expand Up @@ -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`,
}
}

Expand Down
19 changes: 17 additions & 2 deletions test/siteproxylocal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.

0 comments on commit 55b3d5d

Please sign in to comment.