diff --git a/js/modules/link_text.js b/js/modules/link_text.js
index 610d1f104..5354f3da8 100644
--- a/js/modules/link_text.js
+++ b/js/modules/link_text.js
@@ -1,45 +1,39 @@
// Fork of https://github.com/uiureo/link-text with HTML escaping disabled as we leverage
// jQuery’s escaping mechanism:
-var linkify = require('linkify-it')()
-
-function createLink (url, text, attrs) {
- attrs = attrs || {}
-
- var html = []
- html.push('')
- html.push(decodeURIComponent(text))
- html.push('')
-
- return html.join('')
+const linkify = require('linkify-it')();
+
+function createLink(url, text, attrs = {}) {
+ const html = [];
+ html.push(' {
+ html.push(` ${key}="${attrs[key]}"`);
+ });
+ html.push('>');
+ html.push(decodeURIComponent(text));
+ html.push('');
+
+ return html.join('');
}
-module.exports = function (text, attrs) {
- attrs = attrs || {}
+module.exports = (text, attrs = {}) => {
+ const matchData = linkify.match(text) || [];
- var matchData = linkify.match(text) || []
+ const result = [];
+ let last = 0;
- var result = []
- var last = 0
-
- matchData.forEach(function (match) {
+ matchData.forEach((match) => {
if (last < match.index) {
- result.push(text.slice(last, match.index))
+ result.push(text.slice(last, match.index));
}
- result.push(
- createLink(match.url, match.text, attrs)
- )
+ result.push(createLink(match.url, match.text, attrs));
- last = match.lastIndex
- })
+ last = match.lastIndex;
+ });
- result.push(text.slice(last))
+ result.push(text.slice(last));
- return result.join('')
-}
+ return result.join('');
+};