Confirmed lazy loaded javascript files can have "undefined" in cache buster string

Xon

Well-known member
Licensed customer
Affected version
2.3.13
JavaScript:
.map(unloadedHandler =>
{
    const handler = lazyHandlers[unloadedHandler]
    handler.loading = true

    const file = handler.minified && !XF.config.fullJs
        ? handler.file.replace('.js', '.min.js')
        : handler.file
    return jsUrl.replace('__SENTINEL__', file) + '_mt=' + XF.config.jsMt[file] || ''
})
.filter((file, index, self) => self.indexOf(file) === index)

The fragment XF.config.jsMt[file] || '' returns undefined not an empty value. This is because || '' binds after the + not before.

This should be;
Code:
return jsUrl.replace('__SENTINEL__', file) + '_mt=' + (XF.config.jsMt[file] || '')

That said, if file isn't in XF.config.jsMt is there any reason to appending the _mt= clause?

Code:
return jsUrl.replace('__SENTINEL__', file) + (file in XF.config.jsMt ? '_mt=' + XF.config.jsMt[file] : '')
 
Last edited:
Back
Top Bottom