Skip to content

Commit

Permalink
fixed pincong back to home page issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
netptop committed Feb 27, 2020
1 parent 68ad27e commit 591e750
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const regReplaceMap = {
}

const pathReplace = ({host, httpType, body}) => {
let myRe = new RegExp('href=(["]?)[.]?/([-a-z0-9_]+?)', 'g')
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')
Expand Down
18 changes: 16 additions & 2 deletions test/siteproxylocal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ test('google.com regex match issue.', async () => {
url,
})
// console.log(`${JSON.stringify(response.headers)}`)
console.log(`${response.data}`)
// console.log(`${response.data}`)
expect(response.data.indexOf(`href="/https/www.google.com/g);`)).toBe(-1)
}, 30000);
}, 30000);

test('pingcong href="/" issue.', async () => {
const url = `${httpprefix}://${serverName}:${port}/https/pincong.rocks/search/`
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(`href="/"`)).toBe(-1)
}, 30000);

0 comments on commit 591e750

Please sign in to comment.