1 |
|
2 | 'use strict';
|
3 |
|
4 | module.exports = function (url, opts) {
|
5 | opts = opts || {};
|
6 |
|
7 | var ext = (url.indexOf('.') === -1) ? null : url.split('.').pop().replace(/\?.*/, '');
|
8 |
|
9 | var mapping = {
|
10 | atom: 'application/atom+xml',
|
11 | json: 'application/json',
|
12 | rss: 'application/rss+xml',
|
13 | rdf: 'application/rdf+xml',
|
14 | xml: 'application/xml',
|
15 | css: 'text/css',
|
16 | ris: 'application/x-research-info-systems',
|
17 | txt: 'text/plain'
|
18 | };
|
19 | return (mapping.hasOwnProperty(ext) ? mapping[ext] : 'text/html') + (opts.charset ? '; charset=' + opts.charset : '');
|
20 | };
|