-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #6 #23
base: master
Are you sure you want to change the base?
Fixed #6 #23
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore
GitHub and I are not getting along today...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me but I'm just hesitant about the way we handle non-String url
values. Would love to see it merged ASAP! 😄
Also sorry, the review looked weird the first time so I re-posted. 👀
@@ -117,7 +117,7 @@ module.exports = function getPixels(url, type, cb) { | |||
cb = type | |||
type = '' | |||
} | |||
var ext = path.extname(url) | |||
var ext = path.extname(url.toString().split('?')[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not obvious to me what url.toString()
would do if it's not already a String.
I checked, and it looks like path.extname(undefined)
creates an error in Node's path
module (at least the current version), while it returns an empty string for node-browserify
(the browserify built-in which gets included in bundles). That said, the previous line was already relying on non-standard behavior.
What about:
var ext = url ? path.extname(url.split('?')[0]) : ''
or:
var ext = typeof url === 'string' ? path.extname(url.split('?')[0]) : ''
🙂
Before
After
Fixes #6.