Skip to content

Commit 625e641

Browse files
authored
fix(ember): Fix location url for 'hash' location type (#3195)
Hash location does not include root URL when using formatURL, this will check the implementation and add rootURL when location implementation is 'hash'.
1 parent 96e3ef3 commit 625e641

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/ember/addon/instance-initializers/sentry-performance.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ function getTransitionInformation(transition: any, router: any) {
3333
};
3434
}
3535

36+
function getLocationURL(location: any) {
37+
if (!location || !location.getURL || !location.formatURL) {
38+
return '';
39+
}
40+
const url = location.formatURL(location.getURL());
41+
42+
if (location.implementation === 'hash') {
43+
return `${location.rootURL}${url}`;
44+
}
45+
return url;
46+
}
47+
3648
export function _instrumentEmberRouter(
3749
routerService: any,
3850
routerMain: any,
@@ -45,7 +57,7 @@ export function _instrumentEmberRouter(
4557
let activeTransaction: Transaction;
4658
let transitionSpan: Span;
4759

48-
const url = location && location.getURL && location.formatURL && location.formatURL(location.getURL());
60+
const url = getLocationURL(location);
4961

5062
if (macroCondition(isTesting())) {
5163
routerService._sentryInstrumented = true;

0 commit comments

Comments
 (0)