Skip to content

Commit

Permalink
[INTERNAL] TestRunner: Use parseurl module instead of req.path
Browse files Browse the repository at this point in the history
To be compatible with connect middleware APIs
  • Loading branch information
RandomByte committed Mar 12, 2020
1 parent 7e13b8a commit 47a93b0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/middleware/testRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)$/;
Expand Down Expand Up @@ -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];

Expand Down
2 changes: 1 addition & 1 deletion test/lib/server/middleware/testRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {},
Expand Down

0 comments on commit 47a93b0

Please sign in to comment.