-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
36 lines (27 loc) · 765 Bytes
/
test.js
File metadata and controls
36 lines (27 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// 'use strict'; Let PAC-script decide for itself.
const Fs = require('fs');
const Benchmark = require('benchmark');
const args = process.argv.slice(2);
if (args.length !== 1) {
console.error('ARGS: ./buggy.pac');
process.exit(1);
}
const pacPath = args.pop();
const pacEnv = Fs.readFileSync('./env.js');
const executePac = function executePac(pacStr, host) {
return (new Function (
'url', 'host',
pacEnv + ';' + pacStr + '; return FindProxyForURL(url, host);')
)(`http://${host}`, host);
}
const pacStr = Fs.readFileSync(pacPath).toString();
[
'kasparov.ru',
'www.kasparov.ru',
'ru.leonnavi.com',
'ab.leonnavi.com',
'example.com',
].forEach((host) => {
const result = executePac(pacStr, host);
console.log(host, result);
});