remove mime #185
5 changed files with 35 additions and 62 deletions
32
dist/bundle.es.js
vendored
32
dist/bundle.es.js
vendored
|
@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||||
|
|
||||||
require('proxy-polyfill');
|
require('proxy-polyfill');
|
||||||
var mime = _interopDefault(require('mime'));
|
|
||||||
var reselect = require('reselect');
|
var reselect = require('reselect');
|
||||||
var uuid = _interopDefault(require('uuid/v4'));
|
var uuid = _interopDefault(require('uuid/v4'));
|
||||||
|
|
||||||
|
@ -692,29 +691,22 @@ const Lbry = {
|
||||||
|
|
||||||
// Returns a human readable media type based on the content type or extension of a file that is returned by the sdk
|
// Returns a human readable media type based on the content type or extension of a file that is returned by the sdk
|
||||||
getMediaType: (contentType, fileName) => {
|
getMediaType: (contentType, fileName) => {
|
||||||
|
if (fileName) {
|
||||||
const formats = [[/\.(mp4|m4v|webm|flv|f4v|ogv)$/i, 'video'], [/\.(mp3|m4a|aac|wav|flac|ogg|opus)$/i, 'audio'], [/\.(h|go|ja|java|js|jsx|c|cpp|cs|css|rb|scss|sh|php|py)$/i, 'script'], [/\.(json|csv|txt|log|md|markdown|docx|pdf|xml|yml|yaml)$/i, 'document'], [/\.(pdf|odf|doc|docx|epub|org|rtf)$/i, 'e-book'], [/\.(stl|obj|fbx|gcode)$/i, '3D-file'], [/\.(cbr|cbt|cbz)$/i, 'comic-book']];
|
const formats = [[/\.(mp4|m4v|webm|flv|f4v|ogv)$/i, 'video'], [/\.(mp3|m4a|aac|wav|flac|ogg|opus)$/i, 'audio'], [/\.(h|go|ja|java|js|jsx|c|cpp|cs|css|rb|scss|sh|php|py)$/i, 'script'], [/\.(json|csv|txt|log|md|markdown|docx|pdf|xml|yml|yaml)$/i, 'document'], [/\.(pdf|odf|doc|docx|epub|org|rtf)$/i, 'e-book'], [/\.(stl|obj|fbx|gcode)$/i, '3D-file'], [/\.(cbr|cbt|cbz)$/i, 'comic-book']];
|
||||||
|
|
||||||
const extName = mime.getExtension(contentType);
|
|
||||||
const fileExt = extName ? `.${extName}` : null;
|
|
||||||
const testString = fileName || fileExt;
|
|
||||||
|
|
||||||
// Get mediaType from file extension
|
|
||||||
if (testString) {
|
|
||||||
const res = formats.reduce((ret, testpair) => {
|
const res = formats.reduce((ret, testpair) => {
|
||||||
const [regex, mediaType] = testpair;
|
switch (testpair[0].test(ret)) {
|
||||||
|
case true:
|
||||||
return regex.test(ret) ? mediaType : ret;
|
return testpair[1];
|
||||||
}, testString);
|
default:
|
||||||
|
return ret;
|
||||||
if (res !== testString) return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get mediaType from contentType
|
|
||||||
if (contentType) {
|
|
||||||
const matches = /^[^/]+/.exec(contentType);
|
|
||||||
if (matches) {
|
|
||||||
return matches[0];
|
|
||||||
}
|
}
|
||||||
|
}, fileName);
|
||||||
|
return res === fileName ? 'unknown' : res;
|
||||||
|
} else if (contentType) {
|
||||||
|
// $FlowFixMe
|
||||||
|
return (/^[^/]+/.exec(contentType)[0]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'unknown';
|
return 'unknown';
|
||||||
|
|
4
flow-typed/mime.js
vendored
4
flow-typed/mime.js
vendored
|
@ -1,4 +0,0 @@
|
||||||
// @flow
|
|
||||||
declare module 'mime' {
|
|
||||||
declare module.exports: any;
|
|
||||||
}
|
|
|
@ -28,7 +28,6 @@
|
||||||
"format": "prettier 'src/**/*.{js,json}' --write"
|
"format": "prettier 'src/**/*.{js,json}' --write"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"mime": "^2.4.4",
|
|
||||||
"proxy-polyfill": "0.1.6",
|
"proxy-polyfill": "0.1.6",
|
||||||
"reselect": "^3.0.0",
|
"reselect": "^3.0.0",
|
||||||
"uuid": "^3.3.2"
|
"uuid": "^3.3.2"
|
||||||
|
|
31
src/lbry.js
31
src/lbry.js
|
@ -1,6 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import 'proxy-polyfill';
|
import 'proxy-polyfill';
|
||||||
import mime from 'mime';
|
|
||||||
|
|
||||||
const CHECK_DAEMON_STARTED_TRY_NUMBER = 200;
|
const CHECK_DAEMON_STARTED_TRY_NUMBER = 200;
|
||||||
//
|
//
|
||||||
|
@ -34,6 +33,7 @@ const Lbry: LbryTypes = {
|
||||||
|
|
||||||
// Returns a human readable media type based on the content type or extension of a file that is returned by the sdk
|
// Returns a human readable media type based on the content type or extension of a file that is returned by the sdk
|
||||||
getMediaType: (contentType?: string, fileName: ?string) => {
|
getMediaType: (contentType?: string, fileName: ?string) => {
|
||||||
|
if (fileName) {
|
||||||
const formats = [
|
const formats = [
|
||||||
[/\.(mp4|m4v|webm|flv|f4v|ogv)$/i, 'video'],
|
[/\.(mp4|m4v|webm|flv|f4v|ogv)$/i, 'video'],
|
||||||
[/\.(mp3|m4a|aac|wav|flac|ogg|opus)$/i, 'audio'],
|
[/\.(mp3|m4a|aac|wav|flac|ogg|opus)$/i, 'audio'],
|
||||||
|
@ -44,27 +44,18 @@ const Lbry: LbryTypes = {
|
||||||
[/\.(cbr|cbt|cbz)$/i, 'comic-book'],
|
[/\.(cbr|cbt|cbz)$/i, 'comic-book'],
|
||||||
];
|
];
|
||||||
|
|
||||||
const extName = mime.getExtension(contentType);
|
|
||||||
const fileExt = extName ? `.${extName}` : null;
|
|
||||||
const testString = fileName || fileExt;
|
|
||||||
|
|
||||||
// Get mediaType from file extension
|
|
||||||
if (testString) {
|
|
||||||
const res = formats.reduce((ret, testpair) => {
|
const res = formats.reduce((ret, testpair) => {
|
||||||
const [regex, mediaType] = testpair;
|
switch (testpair[0].test(ret)) {
|
||||||
|
case true:
|
||||||
return regex.test(ret) ? mediaType : ret;
|
return testpair[1];
|
||||||
}, testString);
|
default:
|
||||||
|
return ret;
|
||||||
if (res !== testString) return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get mediaType from contentType
|
|
||||||
if (contentType) {
|
|
||||||
const matches = /^[^/]+/.exec(contentType);
|
|
||||||
if (matches) {
|
|
||||||
return matches[0];
|
|
||||||
}
|
}
|
||||||
|
}, fileName);
|
||||||
|
return res === fileName ? 'unknown' : res;
|
||||||
|
} else if (contentType) {
|
||||||
|
// $FlowFixMe
|
||||||
|
return /^[^/]+/.exec(contentType)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'unknown';
|
return 'unknown';
|
||||||
|
|
|
@ -3523,11 +3523,6 @@ mime-types@^2.1.12, mime-types@~2.1.17:
|
||||||
dependencies:
|
dependencies:
|
||||||
mime-db "~1.33.0"
|
mime-db "~1.33.0"
|
||||||
|
|
||||||
mime@^2.4.4:
|
|
||||||
version "2.4.4"
|
|
||||||
resolved "https://registry.yarnpkg.com/mime/-/mime-2.4.4.tgz#bd7b91135fc6b01cde3e9bae33d659b63d8857e5"
|
|
||||||
integrity sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==
|
|
||||||
|
|
||||||
mimic-fn@^1.0.0:
|
mimic-fn@^1.0.0:
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
|
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"
|
||||||
|
|
Loading…
Reference in a new issue