diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..fca7c16 --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/package-lock.json b/package-lock.json index c2da2a9..11fb6f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "escriba", - "version": "2.10.0", + "version": "2.11.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index dd7536c..5cddfdc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "escriba", - "version": "2.10.0", + "version": "2.11.0", "description": "Logging with steroids", "main": "src/index.js", "scripts": { diff --git a/src/http-logger.js b/src/http-logger.js index 4163d07..5cbdb25 100644 --- a/src/http-logger.js +++ b/src/http-logger.js @@ -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) diff --git a/src/response-logger.js b/src/response-logger.js index 951dc1e..b71dcfb 100644 --- a/src/response-logger.js +++ b/src/response-logger.js @@ -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))