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

Names with parenthesis are not matched #97

Closed tuirgin closed 2 years ago

tuirgin commented 2 years ago

Filename matches fail if the actor name and image have parenthesis.

I have the following image in the directory configured as token-replacer's root:

In addition I added a few others when troubleshooting:

The only match that fails is Giant_Beetle_(4HD).svg. I added a log statement to show the contents of the cache, and you can see that of the 4 filenames above, the comma and brackets are all escaped, while the parens are unaltered:

token-replacer.js:891 Token Replacer: Caching root folder: 'data', 'modules/tuirgins-tokens/tokens/dd-glyphs'
token-replacer.js:922 Token Replacer: tr_cachedTokens:
modules/tuirgins-tokens/tokens/dd-glyphs/Giant_Beetle%2C_4HD.svg,modules/tuirgins-tokens/tokens/dd-glyphs/Giant_Beetle_(4HD).svg,modules/tuirgins-tokens/tokens/dd-glyphs/Giant_Beetle_%5B4HD%5D.svg,modules/tuirgins-tokens/tokens/dd-glyphs/Giant_Beetle_%7B4HD%7D.svg

However, when the attempt to match occurs, token-replacer is looking for a pattern with escaped parens:

token-replacer.js:709 Token Replacer: searching for token for giant_beetle_%284hd%29
token-replacer.js:710 Token Replacer: searching for portrait for portrait_giant_beetle_%284hd%29

Here's an export of my console log from which the above code blocks were taken: 202204281019-token_replacer-parenthesis.log

vtt-lair commented 2 years ago

Thanks @tuirgin, I'll have a look at this in the following week. Sorry I've been so quiet, I immigrated and the last 5 months has been hectic.

vtt-lair commented 2 years ago

This should have been fixed with 0.7.1. Note that it's v10 only though