Created
December 31, 2021 15:28
-
-
Save ipcjs/27cc0be485d8c7760dade366fb405884 to your computer and use it in GitHub Desktop.
test pac.txt by node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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