Skip to content

Instantly share code, notes, and snippets.

@ipcjs
Created December 31, 2021 15:28
Show Gist options
  • Save ipcjs/27cc0be485d8c7760dade366fb405884 to your computer and use it in GitHub Desktop.
Save ipcjs/27cc0be485d8c7760dade366fb405884 to your computer and use it in GitHub Desktop.
test pac.txt by node.js
const fs = require('fs')
const pacText = fs.readFileSync('./pac.txt', { encoding: 'utf8' })
const findProxyForURL = (() => {
const __PROXY__ = 'http://127.0.0.1:1080'
function isInNet(host, ip, mast) {
if (host === '127.0.0.1') {
return true
}
return false
}
return eval(`${pacText}\nFindProxyForURL`)
})()
function testUrl(url) {
const u = new URL(url)
return findProxyForURL(url, u.hostname)
}
const urls = [
'https://store.steampowered.com/',
'https://fuck.steampowered.com/',
'https://localhost',
'https://fuck.com',
]
for (const url of urls) {
console.log(`${url} => ${testUrl(url)}`)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment