MrPrimate / tokenizer

Tiny yet capable in-game token editor for Foundry VTT
MIT License
29 stars 26 forks source link

Weird filenames cause tokenizer to break when loaded #38

Closed erithtotl closed 2 years ago

erithtotl commented 3 years ago

Because of the new title functionality, tokenizer can break if you have filenames that contain unusual characters like two underscores in a row.

Replace line 199 of utils.js with: words[i] = (words[i][0]?words[i][0].toUpperCase():'') + words[i].substr(1);

erithtotl commented 3 years ago

I went one step further, this also fixes the issue of the window getting cut off (its stretched because very long filenames)

static titleString (text) { const words = text.trim().split(" ");

for (let i = 0; i < words.length; i++) {
  if (i == 0 || !SKIPPING_WORDS.includes(words[i])) {
    words[i] = (words[i][0]?words[i][0].toUpperCase():'') + words[i].substr(1);
  }
}

return  words.join(" ").substring(0,40);

}

MrPrimate commented 3 years ago

Please explain how it breaks, I cannot replicate this.

Please provide an example name that breaks Tokenizer.