Skip to content

Commit

Permalink
fixed yorkbbs.com href issue
Browse files Browse the repository at this point in the history
  • Loading branch information
netptop committed Feb 28, 2020
1 parent 2f62810 commit ba51290
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,18 @@ const regReplaceMap = {
}

const pathReplace = ({host, httpType, body}) => {
let myRe = new RegExp('href=(["]?)[.]?/([-a-z0-9_]*?)', 'g')
// href="//127.0.0.1:8011/https/n
let myRe = new RegExp(`href=([\"\']?)/([-a-z0-9_]+?)`, 'g')
body = body.replace(myRe, `href=$1/${httpType}/${host}/$2`)

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

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

myRe = new RegExp(` src="/"`, 'g')
body = body.replace(myRe, ` src="/${httpType}/${host}/"`)
/*
myRe = new RegExp(' src=(["\'])//([-a-z0-9]+?)', 'g')
body = body.replace(myRe, ` src=$1//${serverName}:${port}/${httpType}/${host}/$2`)
Expand Down Expand Up @@ -108,6 +114,9 @@ const siteSpecificReplace = {
'quot;https://[.:-a-z0-9A-Z]+?/https/accounts.google.com/ManageAccount': `quot;`,
},
'www.youtube.com': {
'b."get_video_info"': `"${httpprefix}://${serverName}:${port}/https/www.youtube.com/get_video_info"`,
'c<a.C.length': `c<a.C.length&&a.C[c].style`,
// 'a.C.c..style.display=0==b': `a.C[c].style&&a.C[c].style.display=0==b`,
// '/manifest.json': `/https/www.youtube.com/manifest.json`,
// '("url":")/([-a-z0-9]+?)': `$1/https/www.youtube.com/$2`,
// ';this...logo.hidden=!0;': ';',
Expand Down
14 changes: 14 additions & 0 deletions test/siteproxylocal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,17 @@ test('pingcong href="/" issue.', async () => {
console.log(`${response.data}`)
expect(response.data.indexOf(`href="/"`)).toBe(-1)
}, 30000);

test('yorkbbs issue', async () => {
const url = `${httpprefix}://${serverName}:${port}/http/www.yorkbbs.ca/`
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(`ca//http`)).toBe(-1)
}, 30000);

0 comments on commit ba51290

Please sign in to comment.