Skip to content

Commit

Permalink
chore: fix lint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
david-luna committed Feb 24, 2025
1 parent b29d913 commit 7a2a8c7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/mockotlpserver/lib/tunnel.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ function createHttpTunnel(log, target) {
try {
targetUrl = new URL(target);
} catch {
log.warn(`Cannot create a tunnel to target "${target}". The given URL is invalid.`);
log.warn(
`Cannot create a tunnel to target "${target}". The given URL is invalid.`
);
return;
}

const {protocol, host} = targetUrl;
if (protocol !== 'http:' && protocol !== 'https:') {
log.warn(`Cannot create a tunnel to target "${target}". Protocol must be one of: http, https.`);
log.warn(
`Cannot create a tunnel to target "${target}". Protocol must be one of: http, https.`
);
return;
}

Expand All @@ -47,7 +51,9 @@ function createHttpTunnel(log, target) {
// ref: https://www.elastic.co/guide/en/observability/current/apm-api-otlp.html
const contentType = req.headers['content-type'];
if (contentType !== 'application/x-protobuf') {
log.warn(`Content type "${contentType}" may not be accepted by the target server (${target})`);
log.warn(
`Content type "${contentType}" may not be accepted by the target server (${target})`
);
}

const httpFlavor = protocol === 'http:' ? http : https;
Expand All @@ -62,7 +68,7 @@ function createHttpTunnel(log, target) {
tunnelRes.pipe(res);
});
req.pipe(tunnelReq);
}
};
}

module.exports = {
Expand Down

0 comments on commit 7a2a8c7

Please sign in to comment.