File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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-
182172function init ( ) {
183173 setup ( ) ;
184- sampleRUM . collectBaseURL = window . origin ;
174+ sampleRUM . collectBaseURL = new URL ( ` ${ window . hlx . codeBasePath } /` , window . origin ) ;
185175 sampleRUM ( ) ;
186176}
187177
You can’t perform that action at this time.
0 commit comments