mirror of
https://github.com/BreizhHardware/express-prom-bundle.git
synced 2026-01-19 00:37:36 +01:00
18 lines
531 B
JavaScript
18 lines
531 B
JavaScript
'use strict';
|
|
|
|
const UrlValueParser = require('url-value-parser');
|
|
const url = require('url');
|
|
let urlValueParser;
|
|
|
|
module.exports = function(req) {
|
|
// originalUrl is taken, because url and path can be changed
|
|
// by middlewares such as 'router'. Note: this function is called onFinish
|
|
/// i.e. always in the tail of the middleware chain
|
|
const path = url.parse(req.originalUrl || req.url).pathname;
|
|
|
|
if (!urlValueParser) {
|
|
urlValueParser = new UrlValueParser();
|
|
}
|
|
return urlValueParser.replacePathValues(path);
|
|
};
|