Skip to content

Commit

Permalink
fixed "url" issue for reuters.com
Browse files Browse the repository at this point in the history
  • Loading branch information
netptop committed Feb 25, 2020
1 parent d78f72a commit c70303e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ const pathReplace = ({host, httpType, body}) => {
myRe = new RegExp('([:, ]url[(]["\']?)/([-a-z0-9]+?)', 'g')
body = body.replace(myRe, `$1/${httpType}/${host}/$2`)

myRe = new RegExp('("url":")/([-a-z0-9_]+?)', 'g')
body = body.replace(myRe, `$1/${httpType}/${host}/$2`)

myRe = new RegExp('("path":")/([-a-z0-9_]+?)', 'g')
body = body.replace(myRe, `$1/${httpType}/${host}/$2`)

myRe = new RegExp(' action="/([-a-z0-9A-Z]+?)', 'g')
body = body.replace(myRe, ` action="/${httpType}/${host}/$1`)

Expand Down Expand Up @@ -95,7 +101,7 @@ const siteSpecificReplace = {
},
'www.youtube.com': {
// '/manifest.json': `/https/www.youtube.com/manifest.json`,
'("url":")/([-a-z0-9]+?)': `$1/https/www.youtube.com/$2`,
// '("url":")/([-a-z0-9]+?)': `$1/https/www.youtube.com/$2`,
// ';this...logo.hidden=!0;': ';',
// '&&this...': '&&this.$&&this.$.',
},
Expand Down
10 changes: 10 additions & 0 deletions test/siteproxylocal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,13 @@ test('google next click issue', async () => {
// console.log(`${response.data}`)
expect(response.data.indexOf(`href="/search?q=`)).toBe(-1)
}, 30000);

test('reuters.com /article issue', async () => {
const url = `${httpprefix}://${serverName}:${port}/https/cn.reuters.com/`
const response = await axios({
method: 'get',
url,
})
console.log(`${response.data}`)
expect(response.data.indexOf(`"url":"/article`)).toBe(-1)
}, 30000);

0 comments on commit c70303e

Please sign in to comment.