Owdy Posted December 29, 2020 Posted December 29, 2020 Is there way to make links generated automaticly also without that https?
Nathan Explosion Posted January 6, 2021 Posted January 6, 2021 The answer is no - the problem you have is how is the software to know that the entered text is to be automatically turned in to a URL? You can assume that anything with https:// or http:// (or any other URL scheme) is going to be the start of a full URL because, well, it is. But it can't be assumed that other entered text is going to form a URL.
CoffeeCake Posted January 6, 2021 Posted January 6, 2021 Yes, you can do this by altering the configuration of CKEditor. As @Nathan Explosion pointed out, defining what the rules are to do so become the challenge. Consider someone that misses a space between two sentences: Quote Hi there.Question for everyone...how do I know when my easy bake oven is warmed up enough for your recipe? Would "there.Question" be converted to a link? Why? Why not? How about "everyone...how"? You'd need to develop a regular expression to capture all your use cases and ignore what are probably not okay. In the days where there were a limited number of TLDs, it would have been easier, but now there are hundreds. Using the autolink plugin, you can define a custom link regex for both links and e-mail addresses. The default ones depend on http(s) or ftp as a prefix. You're interested in CKEDITOR.config.autolink_urlRegex. /** * Regex used by the [Auto Link](https://ckeditor.com/cke4/addon/autolink) plugin to match URL adresses. * * @cfg {RegExp} [autolink_urlRegex] * @since 4.11.0 * @member CKEDITOR.config */ CKEDITOR.config.autolink_urlRegex = /^(https?|ftp):\/\/(-\.)?([^\s\/?\.#]+\.?)+(\/[^\s]*)?[^\s\.,]$/i; // Regex by Imme Emosol. Owdy 1
CoffeeCake Posted January 6, 2021 Posted January 6, 2021 Here's some fun, on just how complex a problem this is to solve: https://mathiasbynens.be/demo/url-regex Also, see: https://stackoverflow.com/questions/161738/what-is-the-best-regular-expression-to-check-if-a-string-is-a-valid-url
Recommended Posts