Permalink
Browse files

Removed mime; included within express/node_modules

  • Loading branch information...
1 parent 46dfdfa commit 75cc3cd37712270289b6e7bc69c94ce1247f3896 @bbyars committed Jun 12, 2011
View
@@ -1,19 +0,0 @@
-Copyright (c) 2010 Benjamin Thomas, Robert Kieffer
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
View
@@ -1,54 +0,0 @@
-# mime
-
-Support for mapping between file extensions and MIME types. This module uses the latest version of the Apache "mime.types" file (maps over 620 types to 800+ extensions). It is also trivially easy to add your own types and extensions, should you need to do that.
-
-## Install
-
-Install with [npm](http://github.com/isaacs/npm):
-
- npm install mime
-
-## API
-
-### mime.lookup(path) - lookup the type for a file or extension
-
- var mime = require('mime');
-
- mime.lookup('/path/to/file.txt'); // => 'text/plain'
- mime.lookup('file.txt'); // => 'text/plain'
- mime.lookup('.txt'); // => 'text/plain'
- mime.lookup('htm'); // => 'text/html'
-
-### mime.extension(type) - lookup the default extension for type
-
- mime.extension('text/html'); // => 'html'
- mime.extension('application/octet-stream'); // => 'bin'
-
-### mime.charsets.lookup() - map mime-type to charset
-
- mime.charsets.lookup('text/plain'); // => 'UTF-8'
-
-(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.)
-
-## "Can you add support for [some type/extension]?"
-
-Start by adding support for the type in your project using the mime.define() or mime.load() methods (documented below).
-
-If there's a type that is shared across node.js modules, by different people, create an issue here and we'll add it if it makes sense.
-
-If the type in question applies to projects outside the node.js community (e.g. if [IANA](http://www.iana.org/assignments/media-types/) approves a new type) file a [bug with Apache](http://httpd.apache.org/bug_report.html) and create an issue here that links to it.
-
-### mime.define() - Add custom mime/extension mappings
-
- mime.define({
- 'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],
- 'application/x-my-type': ['x-mt', 'x-mtt'],
- // etc ...
- });
-
- mime.lookup('x-sft'); // => 'text/x-some-format'
- mime.extension('text/x-some-format'); // => 'x-sf'
-
-### mime.load(filepath) - Load mappings from an Apache ".types" format file
-
- mime.load('./my_project.types');
@@ -1 +0,0 @@
-module.exports = require('./mime');
View
@@ -1,89 +0,0 @@
-var path = require('path'),
- fs = require('fs');
-
-var mime = module.exports = {
- /** Map of extension to mime type */
- types: {},
-
- /** Map of mime type to extension */
- extensions :{},
-
- /**
- * Define mimetype -> extension mappings. Each key is a mime-type that maps
- * to an array of extensions associated with the type. The first extension is
- * used as the default extension for the type.
- *
- * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
- *
- * @param map (Object) type definitions
- */
- define: function(map) {
- for (var type in map) {
- var exts = map[type];
-
- for (var i = 0; i < exts.length; i++) {
- mime.types[exts[i]] = type;
- }
-
- mime.extensions[type] = exts[0];
- }
- },
-
- /**
- * Load an Apache2-style ".types" file
- *
- * This may be called multiple times (it's expected). Where files declare
- * overlapping types/extensions, the last file wins.
- *
- * @param file (String) path of file to load.
- */
- load: function(file) {
- // Read file and split into lines
- var map = {},
- content = fs.readFileSync(file, 'ascii'),
- lines = content.split(/[\r\n]+/);
-
- lines.forEach(function(line, lineno) {
- // Clean up whitespace/comments, and split into fields
- var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/);
- map[fields.shift()] = fields;
- });
-
- mime.define(map);
- },
-
- /**
- * Lookup a mime type based on extension
- */
- lookup: function(path, fallback) {
- var ext = path.replace(/.*[\.\/]/, '').toLowerCase();
- return mime.types[ext] || fallback || mime.default_type;
- },
-
- /**
- * Return file extension associated with a mime type
- */
- extension: function(mimeType) {
- return mime.extensions[mimeType];
- },
-
- /**
- * Lookup a charset based on mime type.
- */
- charsets: {
- lookup: function (mimeType, fallback) {
- // Assume text types are utf8. Modify mime logic as needed.
- return /^text\//.test(mimeType) ? 'UTF-8' : fallback;
- }
- }
-};
-
-// Load our local copy of
-// http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
-mime.load(path.join(__dirname, 'mime.types'));
-
-// Overlay enhancements we've had requests for (and that seem to make sense)
-mime.load(path.join(__dirname, 'node.types'));
-
-// Set the default type
-mime.default_type = mime.types.bin;
Oops, something went wrong.

0 comments on commit 75cc3cd

Please sign in to comment.