martijnversluis/ChordSheetJS

Support for browser without regex lookbehind

Closed this issue · 2 comments

I have users getting this error:

Screenshot 2023-11-13 at 15 46 28

Line 17138 is this piece of code:

const secondWordPosition = pairLyrics.search(/(?<=\s+)\S/);

(?<=\s+) is a lookbehind that is saddly not supported by 9.08% of users: https://caniuse.com/js-regexp-lookbehind

Would it be possible to add a workaround for these browsers. For example, on safari, it is supported since March 27, 2023 which is not that old and it seems this is the only usage of lookbehind there is inside your code.

Thanks for all the work !

@MercierCorentin Thank your for reaching out! That's a nasty bug, but it should probably not be too hard to rewrite the regex without a lookbehind. I'll put it on the board!

@MercierCorentin I just released this in 8.4.1. Please let me know if this fixes your issue.