aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2020-12-21 21:18:07 -0500
committerEugeniy E. Mikhailov <evgmik@gmail.com>2020-12-21 21:18:07 -0500
commit60627f65e8157c6afd288dcacd0296ddc50d8eaf (patch)
tree645d45cca62467809da007d0e4c09873b0bcd3ee /lib
parent000ee106a73347a888eae87e6a1585383b5f7698 (diff)
downloadpatchfoo-60627f65e8157c6afd288dcacd0296ddc50d8eaf.tar.gz
patchfoo-60627f65e8157c6afd288dcacd0296ddc50d8eaf.zip
Fix presentation of id or name
Before the check was done with regexp which occasionally treated names as IDs, for example if they had ] or & in their names. Now we just check that name is not equal link (i.e. ssb ID). If name is not present than truncated version of the link is shown.
Diffstat (limited to 'lib')
-rw-r--r--lib/render.js13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/render.js b/lib/render.js
index 91bd2ab..3b0e9ac 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -353,9 +353,6 @@ Render.prototype.idLink = function (link, cb) {
return a
}
-// %NM8tXGBBDKKcpRbbyd/5uN1p/2OtBMFDylLMDPGoq8Q=.sha256
-var idRegex = /^[A-Za-z0-9._\-+=/]*[A-Za-z0-9_\-+=/]$/
-
Render.prototype.idLinkCopyable = function (link, cb) {
var self = this
if (!self.app.copyableIds) return idLink(link, cb)
@@ -364,15 +361,15 @@ Render.prototype.idLinkCopyable = function (link, cb) {
self.prepareLink(link, function (err, link) {
if (err) return cb(err)
a.href = self.toUrl(link.link)
- var name = link.name || String(link.link).substr(1, 8) + '…'
- if (idRegex.test(name)) a.childNodes[0].textContent = '@' + name
+ var name = link.name || link.link
+ if (name != link.link) a.childNodes[0].textContent = '@' + name
else {
+ var shortLink = String(link.link).substr(1, 8) + '…'
a.className = 'id-copyable-link'
a.innerHTML = h('span', [
h('span.id-deemphasize', '['),
- h('span.id-name', '@' + link.name),
- h('span.id-deemphasize', ']'
- + '(', h('span.id-inner', link.link), ')'),
+ h('span.id-name', '@' + link.shortLink),
+ h('span.id-deemphasize', ']')
]).innerHTML
}
cb()