Skip to content

Commit

Permalink
Merge 814af56 into 52facfa
Browse files Browse the repository at this point in the history
  • Loading branch information
domasx2 authored Mar 17, 2023
2 parents 52facfa + 814af56 commit a34f668
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/

### :bug: (Bug Fix)

* fix(sdk-trace-web): make `parseUrl()` respect document.baseURI [#3670](https://github.com/open-telemetry/opentelemetry-js/pull/3670) @domasx2
* fix(resource): make properties for async resource resolution optional [#3677](https://github.com/open-telemetry/opentelemetry-js/pull/3677) @pichlermarc
* fix(resources): change fs/promises import to be node 12 compatible [#3681](https://github.com/open-telemetry/opentelemetry-js/pull/3681) @pichlermarc

Expand Down
5 changes: 4 additions & 1 deletion packages/opentelemetry-sdk-trace-web/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,10 @@ export interface URLLike {
*/
export function parseUrl(url: string): URLLike {
if (typeof URL === 'function') {
return new URL(url, location.href);
return new URL(
url,
typeof document !== 'undefined' ? document.baseURI : location.href
);
}
const element = getUrlNormalizingAnchor();
element.href = url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ describe('utils', () => {
assert.strictEqual(typeof url[field], 'string');
});
});

it('should correctly parse relative url in presence of base tag', () => {
sinon.stub(globalThis.document, 'baseURI').value('http://foobar.com');
const url = parseUrl('foo/bar');
assert.strictEqual(url.href, 'http://foobar.com/foo/bar');
});
});

describe('normalizeUrl', () => {
Expand Down

0 comments on commit a34f668

Please sign in to comment.