Closed bauer-git closed 6 years ago
Do you have a reproducible test case?
I saw 10 seconds after I wrote this exactly where you initialize 'regexEscape'.
All I can tell you is I'm using this in Joomla - with the Fabrik extension. If no one else has ever reported this problem, then I assume it's got to be either Joomla, Fabrik, or my browser (latest version of Chrome) that causes/throws the error.
Maybe there is something in either that doesn't allow variables such as what is created when you initialize regexEscape - and all the others done similar fashion? (What var type is that anyhow - is it considered a string?)
Anyhow, I couldn't use your code. Thank you.
Again, do you have a test case that reproduces the problem? Otherwise, there’s nothing I can do.
This can happen with he.encode(undefined)
or he.decode(undefined)
IMHO, if the choice was to not handle undefined
or null
values, an appropriate error could be throw to prevent this usage instead of an Uncaught TypeError
This gave me a surprise too. I think the library should handle the undefined and null cases otherwise we have to write code like he.encode(string || '') all over the place. Or we'll need a wrapper function like
const htmlEncode = (string, options) => typeof string === 'string' ? he.encode(string, options) : '';
When I use this function I get this error... he.js:202 Uncaught TypeError: Cannot read property 'replace' of undefined
Where is 'regexEscape' being initialized?