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

DEBUG_MIME doesn't work #117

Closed
dougwilson opened this issue Feb 8, 2015 · 1 comment · Fixed by #155
Closed

DEBUG_MIME doesn't work #117

dougwilson opened this issue Feb 8, 2015 · 1 comment · Fixed by #155

Comments

@dougwilson
Copy link

It throws ;)

$ DEBUG_MIME=1 node -pe 'require("mime");0'

node_modules\mime\mime.js:26
        console.warn(this._loading.replace(/.*\//, ''), 'changes "' + exts[i]
                                   ^
TypeError: Cannot call method 'replace' of undefined
    at Mime.define (node_modules\mime\mime.js:26:36)
    at Object.<anonymous> (node_modules\mime\mime.js:87:6)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at [eval]:1:1
    at Object.<anonymous> ([eval]-wrapper:6:22)
@WORMSS
Copy link
Contributor

WORMSS commented May 10, 2017

I was trying to figure out what MIME was doing, and noticed some strange usage within the DEBUG_MIME section..

Ironically, it actually failed where @dougwilson has listed.. But even if it didn't, I think it would have failed in a different place if I am reading this correctly.

if (process.env.DEBUG_MIME && this.types[exts]) {
    console.warn(this._loading.replace(/.*\//, ''), 'changes "' + exts[i] + '" extension type from ' +
    this.types[exts] + ' to ' + type);
}

Correct me if I am wrong, but should this.types[exts] not be this.types[exts[i]] Since exts is an array, not a string. It's fine if the array is singular since ["foo"] resolves to "foo", but ["foo", "bar"] resolves to "foo,bar" and so would never be caught correctly.

I think I will make a Pull Request for this.

WORMSS added a commit to WORMSS/node-mime that referenced this issue May 10, 2017
This fixes broofa#117
`this._loading` is undefined/null if calling 'define()' directly, rather than via `load()`.
`exts` incorrectly being used in `this.types[exts]`. Since exts is an array, it only works if the array holds a single value.
broofa added a commit that referenced this issue May 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants