Skip to content

Commit

Permalink
Merge pull request #114 from pagarme/ingore-query-params-on-skipper
Browse files Browse the repository at this point in the history
fix: Skipper ignores search params
  • Loading branch information
lucianopf authored Feb 28, 2023
2 parents c777738 + 67084f5 commit 14b2553
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Run tests

on:
push:
branches:
- master
pull_request:

jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 15.x, 16.x, 18.x, 19.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "escriba",
"version": "2.10.0",
"version": "2.11.0",
"description": "Logging with steroids",
"main": "src/index.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion src/http-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const prepareConfigProps = ({
}

const middleware = (requestLogger, responseLogger, logIdPath, skipper) => (req, res, next) => {
if (skipper(req.url, req.method)) return next()
const path = req.originalUrl.replace(/(\?|\#).*$/, '')
if (skipper(path, req.method)) return next()
req.id = R.path(R.split('.', logIdPath), req) || cuid()
requestLogger(req)
responseLogger(req, res)
Expand Down
3 changes: 2 additions & 1 deletion src/response-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ const captureLog = ({
const { req, res } = http
const { write, end } = res
const chunks = []
const shouldSkipChunk = skipper(req.url, req.method, true)
const path = req.originalUrl.replace(/(\?|\#).*$/, '')
const shouldSkipChunk = skipper(path, req.method, true)

res.write = chunk => {
if (!shouldSkipChunk) chunks.push(Buffer.from(chunk))
Expand Down

0 comments on commit 14b2553

Please sign in to comment.