Skip to content

Commit

Permalink
fix(opentelemetry-instrumentation-http): handle null ports in options (
Browse files Browse the repository at this point in the history
…#2948)

Co-authored-by: Daniel Dyla <[email protected]>
  • Loading branch information
danielgblanco and dyladan authored May 11, 2022
1 parent 97bc632 commit ac578e9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions experimental/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ All notable changes to experimental packages in this project will be documented

### :bug: (Bug Fix)

* fix(opentelemetry-instrumentation-http): use correct origin when port is `null` #2948 @danielgblanco
* fix(otlp-exporter-base): include esm and esnext in package files #2952 @dyladan

### :books: (Refine Doc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,8 @@ export const getRequestInfo = (
if (!pathname && optionsParsed.path) {
pathname = url.parse(optionsParsed.path).pathname || '/';
}
origin = `${optionsParsed.protocol || 'http:'}//${
optionsParsed.host || `${optionsParsed.hostname}:${optionsParsed.port}`
}`;
const hostname = optionsParsed.host || (optionsParsed.port != null ? `${optionsParsed.hostname}${optionsParsed.port}` : optionsParsed.hostname);
origin = `${optionsParsed.protocol || 'http:'}//${hostname}`;
}

const headers = optionsParsed.headers ?? {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,23 @@ describe('Utility', () => {
...urlParsed,
pathname: undefined,
};
const urlParsedWithUndefinedHostAndPort = {
...urlParsed,
host: undefined,
port: undefined,
};
const urlParsedWithUndefinedHostAndNullPort = {
...urlParsed,
host: undefined,
port: null,
};
const whatWgUrl = new url.URL(webUrl);
for (const param of [
webUrl,
urlParsed,
urlParsedWithoutPathname,
urlParsedWithUndefinedHostAndPort,
urlParsedWithUndefinedHostAndNullPort,
whatWgUrl,
]) {
const result = utils.getRequestInfo(param);
Expand Down

0 comments on commit ac578e9

Please sign in to comment.