robots-parser icon indicating copy to clipboard operation
robots-parser copied to clipboard

Crash when passing an invalid URL

Open guiweber opened this issue 11 years ago • 2 comments

It would be nice to handle invalid URLs better instead of crashing. I had to search quite a while why it was not working as it was not clear that robots-parser did not accept an URL without the protocol.

It seems it could be done by validating the result of this call at line 173 in Robots.js

this._url = libUrl.parse(url);

The same validation would also be needed in Robots.prototype.isAllowed

Let me know if you'd like me to submit a pull request for this.

guiweber avatar Mar 09 '15 01:03 guiweber

Hello. This issue still valid for latest version?

keyndark avatar Jan 25 '18 10:01 keyndark

I must have missed the notification for this! Sorry about that.

I've added a fix so it now handles URLs with missing protocols, etc. Thanks for repotting!

samclarke avatar Jan 25 '18 13:01 samclarke