From 981f4fc264213e256e7856d4c2d358cac6ba5327 Mon Sep 17 00:00:00 2001 From: falsandtru Date: Sun, 10 May 2020 09:23:49 +0900 Subject: [PATCH] refactor(middleware): handle paths as URLs --- lib/middleware/karma.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/middleware/karma.js b/lib/middleware/karma.js index 588fa609e..ebe492bb5 100644 --- a/lib/middleware/karma.js +++ b/lib/middleware/karma.js @@ -162,31 +162,27 @@ function createKarmaMiddleware ( const scriptTags = [] for (const file of files.included) { - let filePath = file.path + const urlPath = file.isUrl + ? file.path + : requestUrl === '/context.html' + ? filePathToUrlPath(file.path, basePath, urlRoot, proxyPath) + '?' + file.sha + : filePathToUrlPath(file.path, basePath, urlRoot, proxyPath) const fileType = helper.getFileType(file) if (helper.isDefined(fileType) && !FILE_TYPES.includes(fileType)) { log.warn(`Invalid file type (${fileType}), defaulting to js.`) } - if (!file.isUrl) { - filePath = filePathToUrlPath(filePath, basePath, urlRoot, proxyPath) - - if (requestUrl === '/context.html') { - filePath += '?' + file.sha - } - } - if (fileType === 'css') { - scriptTags.push(``) + scriptTags.push(``) } else if (fileType === 'dom') { scriptTags.push(file.content) } else if (fileType === 'html') { - scriptTags.push(``) + scriptTags.push(``) } else { const scriptType = (SCRIPT_TYPE[fileType] || 'text/javascript') const crossOriginAttribute = includeCrossOriginAttribute ? 'crossorigin="anonymous"' : '' - scriptTags.push(``) + scriptTags.push(``) } }