Skip to content

Commit

Permalink
Merge 266c3e2 into 11a6235
Browse files Browse the repository at this point in the history
  • Loading branch information
cjihrig committed Feb 8, 2019
2 parents 11a6235 + 266c3e2 commit 5f2c6b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async function register (server, options) {

// set a logger for each request
server.ext('onRequest', (request, h) => {
if (options.ignorePaths && ignoreTable[request.url.path]) {
if (options.ignorePaths && ignoreTable[request.url.pathname]) {
request.logger = nullLogger
return h.continue
}
Expand Down Expand Up @@ -106,7 +106,7 @@ async function register (server, options) {

// log when a request completes
tryAddEvent(server, options, 'on', 'response', function (request) {
if (options.ignorePaths && ignoreTable[request.url.path]) {
if (options.ignorePaths && ignoreTable[request.url.pathname]) {
return
}

Expand Down
7 changes: 5 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Lab = require('lab')
const Hoek = require('hoek')
const split = require('split2')
const writeStream = require('flush-write-stream')
const URL = require('url').URL
const promisify = require('util').promisify
const sleep = promisify(setTimeout)

Expand Down Expand Up @@ -1001,7 +1002,8 @@ experiment('ignore request logs for paths in ignorePaths', () => {
resolver = resolve
})
const stream = sink((data) => {
expect(data.req.url).to.not.equal('/ignored')
const url = new URL(data.req.url)
expect(url.pathname).to.equal('/')
resolver()
})
const logger = require('pino')(stream)
Expand Down Expand Up @@ -1037,8 +1039,9 @@ experiment('ignore response logs for paths in ignorePaths', () => {
resolver = resolve
})
const stream = sink((data) => {
const url = new URL(data.req.url)
expect(url.pathname).to.equal('/')
expect(data.msg).to.equal('request completed')
expect(data.req.url).to.not.equal('/ignored')
resolver()
})
const logger = require('pino')(stream)
Expand Down

0 comments on commit 5f2c6b0

Please sign in to comment.