1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-27 11:22:06 +02:00

perf: save ~10ms on player.src call (#6141)

Don't use a case-insensitive regex for getting the extname. Don't try to guess the type if we're provided with one.
This commit is contained in:
Brandon Casey 2019-07-29 16:40:29 -04:00 committed by Gary Katsevman
parent 2e69448f49
commit 2e495dd5f5
2 changed files with 6 additions and 4 deletions

View File

@ -56,10 +56,12 @@ const filterSource = function(src) {
* src Object with known type * src Object with known type
*/ */
function fixSource(src) { function fixSource(src) {
const mimetype = getMimetype(src.src); if (!src.type) {
const mimetype = getMimetype(src.src);
if (!src.type && mimetype) { if (mimetype) {
src.type = mimetype; src.type = mimetype;
}
} }
return src; return src;

View File

@ -132,7 +132,7 @@ export const getAbsoluteURL = function(url) {
*/ */
export const getFileExtension = function(path) { export const getFileExtension = function(path) {
if (typeof path === 'string') { if (typeof path === 'string') {
const splitPathRe = /^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/i; const splitPathRe = /^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/;
const pathParts = splitPathRe.exec(path); const pathParts = splitPathRe.exec(path);
if (pathParts) { if (pathParts) {