From 47a93b037f1e0e4d6f024215af89c53afa02dabf Mon Sep 17 00:00:00 2001 From: Merlin Beutlberger Date: Thu, 12 Mar 2020 14:46:05 +0100 Subject: [PATCH] [INTERNAL] TestRunner: Use parseurl module instead of req.path To be compatible with connect middleware APIs --- lib/middleware/testRunner.js | 3 ++- test/lib/server/middleware/testRunner.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/middleware/testRunner.js b/lib/middleware/testRunner.js index 42458b01..dd9cae64 100644 --- a/lib/middleware/testRunner.js +++ b/lib/middleware/testRunner.js @@ -3,6 +3,7 @@ const fs = require("graceful-fs"); const readFile = promisify(fs.readFile); const path = require("path"); const mime = require("mime-types"); +const parseurl = require("parseurl"); const log = require("@ui5/logger").getLogger("server:middleware:testRunner"); const testRunnerResourceRegEx = /\/test-resources\/sap\/ui\/qunit\/(testrunner\.(html|css)|TestRunner.js)$/; @@ -31,7 +32,7 @@ function serveResource(res, resourcePath, resourceContent) { function createMiddleware({resources}) { return async function(req, res, next) { try { - const pathname = req.path; // TODO: Other middlewares use the parseurl module here but I don't get why + const pathname = parseurl(req).pathname; const parts = testRunnerResourceRegEx.exec(pathname); const resourceName = parts && parts[1]; diff --git a/test/lib/server/middleware/testRunner.js b/test/lib/server/middleware/testRunner.js index fef9296a..93a3ae28 100644 --- a/test/lib/server/middleware/testRunner.js +++ b/test/lib/server/middleware/testRunner.js @@ -23,7 +23,7 @@ function callMiddleware(reqPath) { const middleware = testRunnerMiddleware({resources: {}}); return new Promise((resolve, reject) => { const req = { - path: reqPath + url: `http://localhost${reqPath}` }; const res = { setHeader: function() {},