If I have a folder name with a dot, like "/Users/tommie/Git/Github.com/my-project/my-file.mp3", then it is recognized as a url and tries to find a youtube video by id instead, which of course will fail.
I played around a bit with the regex and tried multiple urls + linux/unix and windows folders with dots and it seem to work as expected with my proposed fix below (do not allow any slash before the url, by this in the start: ^(?!\/)):
Today:
const urlRe = /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)/g
Replace with:
const urlRe = /^(?!\/)(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)/g
If I have a folder name with a dot, like "/Users/tommie/Git/Github.com/my-project/my-file.mp3", then it is recognized as a url and tries to find a youtube video by id instead, which of course will fail.
I played around a bit with the regex and tried multiple urls + linux/unix and windows folders with dots and it seem to work as expected with my proposed fix below (do not allow any slash before the url, by this in the start: ^(?!\/)):
Today:
const urlRe = /(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)/gReplace with:
const urlRe = /^(?!\/)(http(s)?:\/\/.)?(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)/g