Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 4c606a4

Browse files
author
Michal Vlasák
committed
Use originalUrl in matchPath util
1 parent c82db33 commit 4c606a4

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ All those log messages will contain request and possibly response, error, time f
116116
### Request skipping
117117
You might want to omit some requests from logging completely. Right now, there are two ways to do it.
118118
1) Use `options.ignoredHttpMethods` to define an array of HTTP methods you want to omit. By default all `OPTIONS` requests are ommited. See [options](#options) for details
119-
2) Use `options.skip` method to define custom rules for requests skipping. Set it to a function which accepts an Express's `Request` and returns `boolean`. If the return value is `true`, request (and corresponding response) will not be logged. You might want to use `matchPath` helper to ignore requests based on the [`req.path` value](https://expressjs.com/en/4x/api.html#req.path)
119+
2) Use `options.skip` method to define custom rules for requests skipping. Set it to a function which accepts an Express's `Request` and returns `boolean`. If the return value is `true`, request (and corresponding response) will not be logged. You might want to use `matchPath` helper to ignore requests based on the [`req.originalUrl` value](https://expressjs.com/en/4x/api.html#req.originalUrl)
120120

121121
```js
122122
const { matchPath } = require('cosmas/utils');

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ import omit = require('omit-deep');
66
const removeEmpty = (obj: Dictionary<any>): object =>
77
omit(obj, Object.keys(obj).filter(key => obj[key] === undefined || isEmpty(obj[key])));
88

9-
const matchPath = (pattern: RegExp) => (req: Request): boolean => req.path.match(pattern) !== null;
9+
const matchPath = (pattern: RegExp) => (req: Request): boolean => req.originalUrl.match(pattern) !== null;
1010

1111
export { removeEmpty, matchPath };

0 commit comments

Comments
 (0)