Closed Twisterking closed 3 years ago
After some digging (tks @berreis), I've discovered that the problem lies in PostRule.js:89
:
for (const i in arr) {
const p = parser.parse(arr[i]);
...
for ... in
in Arrays is susceptible to Prototype overrides. So, if somewhere in your code you have something like:
Array.prototype.something = function() { ...
The loop above will run into:
for (const i = 'something' in arr) {
const p = parser.parse(arr['something']);
And, since arr['something']
is a function
, the code will proceed and that function will get into o.str
and o.rule
. And, since functions have no substr
, _shorten()
will break.
This can also happen if your prototype override is a number, a boolean or anything else that's not a string.
I will submit a PR changing the for in
approach to a for of
, which is the recommend approach for Arrays in JS.
Error:
with the country 'AT':
After some debugging:
it seems like that
o
andcap0
are bothfunction
s!!Please fix, this is very annoying as this completely breaks the whole library for me 😢