Skip to content

Commit

Permalink
fix: use Node 6 compatible features
Browse files Browse the repository at this point in the history
  • Loading branch information
jimlambie committed Jul 18, 2018
1 parent 9a266c3 commit a17b07a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/index.js
@@ -1,4 +1,5 @@
const { URLSearchParams } = require('url')
const querystring = require('querystring')
const url = require('url')

class LogFilter {
constructor (req, filter) {
Expand All @@ -20,18 +21,17 @@ class LogFilter {
return this.req.url
}

let parts = this.req.url.split('?')
let parsedUrl = url.parse(this.req.url, true)

let path = parts[0]
let searchParams = new URLSearchParams(parts[1])
let searchParams = parsedUrl.query

this.filter.forEach(key => {
if (searchParams.get(key)) {
searchParams.set(key, '[FILTERED]')
if (searchParams[key]) {
searchParams[key] = '[FILTERED]'
}
})

return `${path}?${searchParams}`
return `${parsedUrl.pathname}?${querystring.encode(searchParams)}`
}
}

Expand Down

0 comments on commit a17b07a

Please sign in to comment.