neyric/node-google-tools — pull request #3 by brunoduran (2013-05-27 16:49:52+00:00)
Title: Fix to the position function

Some elements of the array of results passed by the function ```search``` to its callback can be undefined. This isn't handled by the function ```position``` which don't check it before trying to access to its properties. It can be seen easily with the next simple script:

```javascript
var google = require("google-tools");

var options = {
url:"https://github.com",
q:"SOME QUERY ABOUT SOMETHING",
num:100,
start:0
};

google.position(options,function(err, r){
//Some callback
});
```

What returns the error:

```Cannot call method 'substr' of undefined```

It can be avoided checking the element of the array before acceding its properties. This implementation could not fix the root problem but would regain the functionality, which is currently broken.