WebOptimizer icon indicating copy to clipboard operation
WebOptimizer copied to clipboard

Uncaught SyntaxError: Unexpected token in minified file

Open edika99 opened this issue 1 year ago • 0 comments

This function is not minified propperly, generating a bad js file with incorrect syntax:

const escapeHTML = str => str.replace(/[&<>'"]/g, tag => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', "'": '&#39;', '"': '&quot;' }[tag]));

generate this invalid js

const escapeHTML=n=>n.replace(/[&<>'"]/g,n=>{"&":"&amp;","<":"&lt;",">":"&gt;","'":"&#39;",'"':"&quot;"}[n])

giving in the browser this error that compromise the load of the entire page

common.js:1 Uncaught SyntaxError: Unexpected token ':' (at common.js:1:5829)

edika99 avatar Nov 19 '23 15:11 edika99