improve link testing

This commit is contained in:
Hans Pagel
2020-11-24 17:26:47 +01:00
parent 098c83f964
commit 5685cf83a4
4 changed files with 77 additions and 29 deletions

View File

@@ -8,7 +8,8 @@ export interface LinkOptions {
},
}
export const pasteRegex = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b(?:[-a-zA-Z0-9@:%._+~#=?!&/()]*)/gi
export const pasteRegex = /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z]{2,}\b(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)/gi
export const pasteRegexWithBrackets = /(?:\()https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z]{2,}\b(?:[-a-zA-Z0-9@:%._+~#=?!&/()]*)(?:\))/gi
const Link = Mark.create({
name: 'link',
@@ -70,6 +71,7 @@ const Link = Mark.create({
addPasteRules() {
return [
markPasteRule(pasteRegex, this.type, (url: string) => ({ href: url })),
markPasteRule(pasteRegexWithBrackets, this.type, (url: string) => ({ href: url })),
]
},