diff options
Diffstat (limited to 'core/src/OCP/comments.js')
-rw-r--r-- | core/src/OCP/comments.js | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/core/src/OCP/comments.js b/core/src/OCP/comments.js index 1500e1937c3..2e12accddce 100644 --- a/core/src/OCP/comments.js +++ b/core/src/OCP/comments.js @@ -18,34 +18,34 @@ import $ from 'jquery' * The downside: anything not ascii is excluded. Not sure how common it is in areas using different * alphabets… the upside: fake domains with similar looking characters won't be formatted as links */ -const urlRegex = /(\s|^)(https?:\/\/)?((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|$)/ig; +const urlRegex = /(\s|^)(https?:\/\/)?((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|$)/ig -export function plainToRich (content) { - return this.formatLinksRich(content); +export function plainToRich(content) { + return this.formatLinksRich(content) } -export function richToPlain (content) { - return this.formatLinksPlain(content); +export function richToPlain(content) { + return this.formatLinksPlain(content) } -export function formatLinksRich (content) { - return content.replace(urlRegex, function (_, leadingSpace, protocol, url, trailingSpace) { - let linkText = url; +export function formatLinksRich(content) { + return content.replace(urlRegex, function(_, leadingSpace, protocol, url, trailingSpace) { + let linkText = url if (!protocol) { - protocol = 'https://'; + protocol = 'https://' } else if (protocol === 'http://') { - linkText = protocol + url; + linkText = protocol + url } - return leadingSpace + '<a class="external" target="_blank" rel="noopener noreferrer" href="' + protocol + url + '">' + linkText + '</a>' + trailingSpace; - }); + return leadingSpace + '<a class="external" target="_blank" rel="noopener noreferrer" href="' + protocol + url + '">' + linkText + '</a>' + trailingSpace + }) } -export function formatLinksPlain (content) { - const $content = $('<div></div>').html(content); - $content.find('a').each(function () { - const $this = $(this); - $this.html($this.attr('href')); - }); - return $content.html(); +export function formatLinksPlain(content) { + const $content = $('<div></div>').html(content) + $content.find('a').each(function() { + const $this = $(this) + $this.html($this.attr('href')) + }) + return $content.html() } |