Răsfoiți Sursa

Add dev comment for the regex part.

panr 5 ani în urmă
părinte
comite
6c03572a0d
1 a modificat fișierele cu 1 adăugiri și 0 ștergeri
  1. 1 0
      packages/ckeditor5-link/src/linkui.js

+ 1 - 0
packages/ckeditor5-link/src/linkui.js

@@ -161,6 +161,7 @@ export default class LinkUI extends Plugin {
 			// This will cover more dynamic cases, when protocol might change after the element has been rendered.
 			// This will cover more dynamic cases, when protocol might change after the element has been rendered.
 			const defaultProtocol = editor.config.get( 'link.defaultProtocol' );
 			const defaultProtocol = editor.config.get( 'link.defaultProtocol' );
 
 
+			// The regex checks for the protocol syntax ('xxxx://') or non-word charecters at the begining of the link ('/', '#' etc.).
 			const isProtocolNeeded = !!defaultProtocol && !( /^((\w+:(\/{2,})?)|(\W))/gmi ).test( value );
 			const isProtocolNeeded = !!defaultProtocol && !( /^((\w+:(\/{2,})?)|(\W))/gmi ).test( value );
 			const isEmail = ( /[\w-]+@[\w-]+\.+[\w-]+/gmi ).test( value );
 			const isEmail = ( /[\w-]+@[\w-]+\.+[\w-]+/gmi ).test( value );