Comparing version 5.0.6 to 5.0.7
'use strict' | ||
const path = require('path') | ||
/** | ||
@@ -32,2 +34,10 @@ * File object used for tracking files in `file-list.js`. | ||
/** | ||
* Detect type from the file extension. | ||
* @returns {string} detected file type or empty string | ||
*/ | ||
detectType () { | ||
return path.extname(this.path).substring(1) | ||
} | ||
toString () { | ||
@@ -34,0 +44,0 @@ return this.path |
@@ -14,5 +14,3 @@ /** | ||
const path = require('path') | ||
const url = require('url') | ||
const helper = require('../helper') | ||
@@ -168,6 +166,14 @@ const log = require('../logger').create('middleware:karma') | ||
let filePath = file.path | ||
const fileType = file.type || path.extname(filePath).substring(1) | ||
const fileType = file.type || file.detectType() | ||
if (helper.isDefined(fileType) && !FILE_TYPES.includes(fileType)) { | ||
log.warn(`Invalid file type (${fileType}), defaulting to js.`) | ||
if (!FILE_TYPES.includes(fileType)) { | ||
if (file.type == null) { | ||
log.warn( | ||
`Unable to determine file type from the file extension, defaulting to js.\n` + | ||
` To silence the warning specify a valid type for ${file.originalPath} in the configuration file.\n` + | ||
` See http://karma-runner.github.io/latest/config/files.html` | ||
) | ||
} else { | ||
log.warn(`Invalid file type (${file.type || 'empty string'}), defaulting to js.`) | ||
} | ||
} | ||
@@ -174,0 +180,0 @@ |
'use strict' | ||
const path = require('path') | ||
const { URL } = require('url') | ||
/** | ||
@@ -9,2 +12,3 @@ * Url object used for tracking files in `file-list.js`. | ||
this.path = path | ||
this.originalPath = path | ||
this.type = type | ||
@@ -14,2 +18,10 @@ this.isUrl = true | ||
/** | ||
* Detect type from the file extension in the path part of the URL. | ||
* @returns {string} detected file type or empty string | ||
*/ | ||
detectType () { | ||
return path.extname(new URL(this.path).pathname).substring(1) | ||
} | ||
toString () { | ||
@@ -16,0 +28,0 @@ return this.path |
@@ -480,3 +480,3 @@ { | ||
}, | ||
"version": "5.0.6", | ||
"version": "5.0.7", | ||
"license": "MIT", | ||
@@ -483,0 +483,0 @@ "husky": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
497655
10355
10