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

/js directory mime is application/javascript. Is it correct? #47

Closed
kadishmal opened this issue Dec 24, 2012 · 1 comment
Closed

/js directory mime is application/javascript. Is it correct? #47

kadishmal opened this issue Dec 24, 2012 · 1 comment

Comments

@kadishmal
Copy link

Trying to get a mime type of a directory in /js request.uri, the module returns application/javascript. Is this the expected behavior? If it is, please explain why.

In my application, when a request comes for a static file, I check whether user has access to this type of static resource. For this reason I need to determine the file mime. Sometime when users enter /js, /css, in which case mime module returns as if request comes for JS or CSS files, respectively. Obviously, this is a wrong behavior.

The expected behavior in such cases is to receive null or '' (an empty string) which would be easy to handle in the application.

@broofa
Copy link
Owner

broofa commented Dec 24, 2012

node-mime is only looking at the name string you give it; it does not use any filesystem information to determine mime type. I agree this case is debatable, but I don't think it's unreasonable to expect people who care about directory .vs. file type to do the necessary checks before calling into node-mime.

@broofa broofa closed this as completed Dec 24, 2012
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

No branches or pull requests

2 participants