fix(extension/link): 🐛 fix last word value not being passed through when undefined (#3258)

This commit is contained in:
Dominik 2022-09-30 04:40:33 +02:00 committed by GitHub
parent 801b436d7a
commit 69923e2b0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,9 +89,18 @@ export function autolink(options: AutolinkOptions): Plugin {
if (textBlock && textBeforeWhitespace) {
const wordsBeforeWhitespace = textBeforeWhitespace.split(' ').filter(s => s !== '')
if (wordsBeforeWhitespace.length <= 0) {
return false
}
const lastWordBeforeSpace = wordsBeforeWhitespace[wordsBeforeWhitespace.length - 1]
const lastWordAndBlockOffset = textBlock.pos + textBeforeWhitespace.lastIndexOf(lastWordBeforeSpace)
if (!lastWordBeforeSpace) {
return false
}
find(lastWordBeforeSpace)
.filter(link => link.isLink)
.filter(link => {