Open RogerHardiman opened 4 years ago
Found the bug
key.startPoint = lines[0].indexOf(key.string);
When processing the 2nd Key (which is 'name') it finds 'name' at Position 4 in this string (and not at position 20)
FullName_ _ _ _ _ _ _ _Name_ _ _ _ _ _ _ _ _ _SID
NOTE spaces changed to underscores for clarity
Would it be better to set the Start Point to the size of the previous key + 1 ?
This workaround fixes it, using a new variable startPoint
function buildDataArray(rawInput){
var lines = rawInput.toString().trim().split('\n'),
data = [],
keys = [],
linePattern = /(\S*?\s\s+)/g,
match,
startPoint=0; // ADDED BY ROGER
while ((match = linePattern.exec(lines[0])) !== null) {
if (match.index === linePattern.lastIndex) {
linePattern.lastIndex++;
}
var key = {};
key.string = match[0].trim();
key.startPoint = startPoint;//lines[0].indexOf(key.string); // CHANGED BY ROGER
key.keyLength = match[0].length;
keys.push(key);
startPoint = key.startPoint + key.keyLength; // ADDED BY ROGER
}
Looks good, thanks. Would you submit a PR?
Hi Yes, will fork and do a PR when I get some spare time.
Roger
I have a problem with the library parsing the results of the wmic command From the command line I can execute this
and I get this back
However when I try this with the wmic library I get this output
My Javascript is
I assume there is a bug when parsing the text returned from the wmic command