From 57df35f6a5861a60f01f8f5d718dcf61b5e93f6c Mon Sep 17 00:00:00 2001 From: ivaosthu Date: Mon, 18 Dec 2017 15:12:44 +0100 Subject: [PATCH] Fix pathname reporting in middlewares --- lib/middleware/request-logger.js | 4 +++- lib/middleware/response-time.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/middleware/request-logger.js b/lib/middleware/request-logger.js index 10ac27644a..4916f51d59 100644 --- a/lib/middleware/request-logger.js +++ b/lib/middleware/request-logger.js @@ -1,12 +1,14 @@ 'use strict'; +const url = require('url'); const logger = require('../logger')('HTTP'); module.exports = function(config) { return (req, res, next) => { next(); if (config.enableRequestLogger) { - logger.info(`${res.statusCode} ${req.method} ${req.baseUrl}`); + const { pathname } = url.parse(req.originalUrl); + logger.info(`${res.statusCode} ${req.method} ${pathname}`); } }; }; diff --git a/lib/middleware/response-time.js b/lib/middleware/response-time.js index 4b4ee140bd..724bb8b89a 100644 --- a/lib/middleware/response-time.js +++ b/lib/middleware/response-time.js @@ -1,12 +1,14 @@ 'use strict'; +const url = require('url'); const responseTime = require('response-time'); const { REQUEST_TIME } = require('../events'); module.exports = function(config) { return responseTime((req, res, time) => { + const { pathname } = url.parse(req.originalUrl); const timingInfo = { - path: req.baseUrl, + path: pathname, method: req.method, statusCode: res.statusCode, time,