Skip to content

Commit

Permalink
perf: save ~10ms on player.src call (#6141)
Browse files Browse the repository at this point in the history
Don't use a case-insensitive regex for getting the extname. Don't try to guess the type if we're provided with one.
  • Loading branch information
brandonocasey authored and gkatsev committed Jul 29, 2019
1 parent 2e69448 commit 2e495dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/js/utils/filter-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ const filterSource = function(src) {
* src Object with known type
*/
function fixSource(src) {
const mimetype = getMimetype(src.src);
if (!src.type) {
const mimetype = getMimetype(src.src);

if (!src.type && mimetype) {
src.type = mimetype;
if (mimetype) {
src.type = mimetype;
}
}

return src;
Expand Down
2 changes: 1 addition & 1 deletion src/js/utils/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const getAbsoluteURL = function(url) {
*/
export const getFileExtension = function(path) {
if (typeof path === 'string') {
const splitPathRe = /^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/i;
const splitPathRe = /^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/;
const pathParts = splitPathRe.exec(path);

if (pathParts) {
Expand Down

0 comments on commit 2e495dd

Please sign in to comment.