vtt-lair / token-replacer

Foundry VTT - Automatically replace NPC actor tokens and/or portraits dependent on token assets saved in a defined folder structure
MIT License
5 stars 4 forks source link

Change encoded symbols to escaped for comparison. #102

Closed vvechkanov closed 2 years ago

vvechkanov commented 2 years ago

Non-UTF symbols are treated differently in the code. Symbols are encoded (using encodeURI) when files are read from the file system, and in the tr_cachedTokens files are stored in an encoded way (example: %D0%A8). And when we try to find the file, we read the name of the character, and escape it- so the name is stored as ("%u0440"). These two ways of storing symbols are not equal, so comparison not working if such symbols are in the token name (any non-English characters). Here is the simplest change to fix that problem.

Feel free to ping me in discord for any questions (ВладимирВ#8162)

P.S. I am not JS developer, I prefer Java/Kotlin/C, so may be there is a better way to do that fix.