Skip to content

Commit 5594518

Browse files
authored
Merge pull request #660 from adobe/update-lib-aem-patch-3-1-8
fix(lib): update scripts/aem.js to aem.js@3.1.8
2 parents baa7ca0 + d2e0da4 commit 5594518

1 file changed

Lines changed: 3 additions & 13 deletions

File tree

‎scripts/aem.js‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,31 +157,21 @@ function sampleRUM(checkpoint, data) {
157157
/**
158158
* Setup block utils.
159159
*/
160-
function setup() {
160+
function setup(importUrl = import.meta.url) {
161161
window.hlx = window.hlx || {};
162162
window.hlx.RUM_MASK_URL = 'full';
163163
window.hlx.RUM_MANUAL_ENHANCE = true;
164-
window.hlx.codeBasePath = '';
165164
window.hlx.lighthouse = new URLSearchParams(window.location.search).get('lighthouse') === 'on';
166165

167-
const scriptEl = document.querySelector('script[src$="/scripts/scripts.js"]');
168-
if (scriptEl) {
169-
try {
170-
[window.hlx.codeBasePath] = new URL(scriptEl.src).pathname.split('/scripts/scripts.js');
171-
} catch (error) {
172-
// eslint-disable-next-line no-console
173-
console.log(error);
174-
}
175-
}
166+
[window.hlx.codeBasePath] = new URL(importUrl).pathname.split('/scripts/');
176167
}
177168

178169
/**
179170
* Auto initialization.
180171
*/
181-
182172
function init() {
183173
setup();
184-
sampleRUM.collectBaseURL = window.origin;
174+
sampleRUM.collectBaseURL = new URL(`${window.hlx.codeBasePath}/`, window.origin);
185175
sampleRUM();
186176
}
187177

0 commit comments

Comments
 (0)