Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Titus <tituswormer@gmail.com>
  • Loading branch information
Murderlon and wooorm committed Sep 15, 2023
1 parent 5822c6b commit 662c54d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ function filterHeaders(allowedHeaders) {
const filteredHeaders = {}

for (const [key, bool] of allowedHeaders.entries()) {
if (incomingHeaders.has(key.toLowerCase()) && bool) {
// @ts-ignore
filteredHeaders[key] = incomingHeaders.get(key.toLowerCase())
const value = incomingHeaders.get(key.toLowerCase())

if (value !== null && value !== undefined && bool) {
filteredHeaders[key] = value
}
}

Expand Down Expand Up @@ -79,8 +80,7 @@ export class Server extends EventEmitter {
return this.write(res, 405, 'Method not allowed')
}

// @ts-ignore req.url is fine
const paths = url.parse(req.url)?.path?.split('/')
const paths = url.parse(req.url || '')?.path?.split('/')

if (!paths || paths.length < 3) {
return this.write(res, 404, 'Malformed request')
Expand All @@ -96,8 +96,8 @@ export class Server extends EventEmitter {
try {
var validUrl = await SafeHttpClient.checkUrl(decodedUrl)
} catch (err) {
// @ts-ignore err does have message
return this.write(res, 400, err.message)
const exception = /** @type {Error} */ (err)
return this.write(res, 400, exception.message)
}

const controller = new AbortController()
Expand Down

0 comments on commit 662c54d

Please sign in to comment.