PlaceholderAPI / Javascript-Expansion

Adds javascript placeholders
GNU General Public License v3.0
22 stars 24 forks source link

Empty arguments don't get interpreted correctly #17

Open CreepyCre opened 4 years ago

CreepyCre commented 4 years ago

javascript_identifier_ has args.length = 1, while javascript_identifier_, has args.length = 0

javascript_identifier_,,somevalue has args.length = 3, while javascript_identifier_somevalue,, has args.length = 1

Expected behaviour would be that args.length = amount of commas + 1 in every case. It seems that it will only parse arguments until the last argument with a non empty string. Empty arguments should be arguments as well for consistency.

BlitzOffline commented 3 years ago

I believe every argument that is empty should or is skipped. Or at least that's what this line is telling me.

CreepyCre commented 3 years ago

The individual args ending up as null is not an issue here, it will not influence the length. The actual cause is located here. If you check the javadocs for String#split, you will see that without specifying a limit it will default to 0, which will drop any trailing empty Strings. The solution here is to use any negative integer as the limit.