afbobak / nopar

Node PAckage Registry
http://afbobak.github.io/nopar/
Other
42 stars 13 forks source link

Prevent JSON.parse to throw an error when receiving invalid metadata #25

Closed mawrkus closed 9 years ago

mawrkus commented 9 years ago

Indeed, I've noticed an erroneous edge case:

The request goes to https://registry.npmjs.org/favicon.ico, which usually returns a 404 but sometimes returns a valid 200 with an icon file, causing JSON.parse to throw an error.

glenjamin commented 9 years ago

Would you be able to add a testcase which covers this scenario?

mawrkus commented 9 years ago

@glenjamin Sure, I'm looking at it

afbobak commented 9 years ago

+1 I've noticed that as well. As soon as you have a testcase I'd love to see this merged!

mawrkus commented 9 years ago

My humble attempt: https://github.com/mawrkus/nopar/commit/cd75aa611bb577a8098c0269a394d024f5d54da6

Let me know.

mawrkus commented 9 years ago

Hi guys,

Any feedback? Should I open an issue and leave it for later?

mawrkus commented 9 years ago

How stupid, sorry. Fixed.