BlitzKraig / fvtt-SoundBoard

Gamemaster Soundboard for Foundry VTT
MIT License
20 stars 17 forks source link

Soundboard not finding folder if path has multiple spaces #90

Open rikmarais opened 1 year ago

rikmarais commented 1 year ago

Hi there 👋 I'm not certain whether this is in some way related to issue #89, but I can reproduce this on Forge and on locally hosted Foundry. Tested with Foundry 10.291 and Soundboard 1.7.1.

Perhaps both that issue and this issue are related to path escaping in some way.

Setting the Custom Soundboard Directory sometimes doesn't work

Common denominator seems to be number of spaces, and not special characters, but I didn't look deeply into the code. Hopefully this helps out in finding the issue!

image image image image

rikmarais commented 1 year ago

I think I figured it out.

We encountered another case with spaces in the path, however this time it was on Forge specifically Game Data/Data/music/Soundboard image

I checked the code and found why the issue was happening in Foundry when there are multiple spaces, too.

The problem is in soundboard.js line 692 and 778, where the returned target is matched to the configured Soundboard Custom Directory image

Likely dependent on the OS running the Foundry Server, the target isn't always returned with URL escaped spaces. So doing a .replace(' ', '%20') won't always be necessary.

Similarly, .replace will only replace 1 instance of a space, which is why we ran into the problem on Foundry Local running on Windows as soon as more than one space appeared.

Maybe the thing to do is to do a double comparison for both Forge and Foundry local cases: If the target with all spaces replaced matches the setting, OR the target with no spaces replaced matches the setting, proceed