data has no method 'indexOf' (Missing conversion .toString() in stdout.on("data" ..) ?
krauskopf opened this issue · 2 comments
krauskopf commented
In index.js at line 76: When subscribing to stdin, shouldn't the data argument be converted to a string before using the method indexOf()?
I'm receiving:
TypeError: Object <?xml version="1.0"?>
<?xml-stylesheet href="file:///usr/bin/../share/nmap/nmap.xsl" type="text/xsl"?>
<!-- Nmap 6.00 scan initiated Fri Feb 19 22:40:35 2016 as: nmap -oX - -sP 192.168.0.1-5 -->
<nmaprun scanner="nmap" args="nmap -oX - -sP 192.168.0.1-5" start="1455918035" startstr="Fri Feb 19 22:40:35 2016" version="6.00" xmloutputversion="1.04">
has no method 'indexOf' at Socket.<anonymous> ( /home/pi/.node-red/node_modules/node-red-contrib-nmap/node_modules/node-nmap/index.js:76:26)
I fixed the issue by adding:
data = data.toString();
to result in:
this.child.stdout.on("data", function (data) {
data = data.toString();
if (data.indexOf("percent") > -1) {
console.log(data.toString());
}
else {
_this.rawData += data;
}
});
I'm using Node.js v0.10.35
harryhorton commented
Thanks for the heads up. I'll check this out and implement the fix.
harryhorton commented
Appologies for the insane delay. It's been a dev heavy year. I'm not seeing an error here. Is this still an issue?