mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-10-05 07:31:53 +00:00
Update hosts.js
This commit is contained in:
parent
1ef81ad19a
commit
d39a2c7d0b
19
lib/hosts.js
19
lib/hosts.js
|
@ -11,22 +11,17 @@ exports.getHosts = function() {
|
|||
var filePath = SYS.getEnvString("windir") + "\\System32\\\drivers\\etc\\hosts";
|
||||
var fileContent = FILE.readFile(filePath, "utf-8");
|
||||
|
||||
var lines = fileContent.split(/[\r\n]+/g).filter(function(s) {
|
||||
return !(s.indexOf(' #') == 0)
|
||||
var rows = fileContent.split(/[\r\n]+/g).filter(function(s) {
|
||||
return !(s.indexOf('#') == 0);
|
||||
}).map(function(s) {
|
||||
var pos = s.indexOf(' #');
|
||||
if(pos > -1) {
|
||||
return s.substring(pos).replace(/\s\s/g, ' ');
|
||||
} else {
|
||||
return s.replace(/\s\s/g, ' ');
|
||||
}
|
||||
var pos = s.indexOf(" #");
|
||||
return (pos > -1 ? s.substring(0, pos) : s).split(/\s+/);
|
||||
});
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var col = lines[i].split(' ');
|
||||
for (var i = 0; i < rows.length; i++) {
|
||||
hosts.push({
|
||||
host: col[0],
|
||||
domain: col[1]
|
||||
host: rows[i][0],
|
||||
domain: rows[i][1]
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user