Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dom-pixels.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Copy link
Collaborator

@benwiley4000 benwiley4000 Jul 14, 2017

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]) : ''

🙂

switch(type || ext.toUpperCase()) {
case '.GIF':
httpGif(url, cb)
Expand Down