Improved URLs with urlencoding display
This commit is contained in:
parent
a6d2214b84
commit
3afe7e7fec
@ -1664,13 +1664,20 @@ angular.module('izhukov.utils', [])
|
|||||||
skipEntity = true
|
skipEntity = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
var url = entity.url || entityText
|
var inner
|
||||||
url = wrapUrl(url, entity._ == 'messageEntityTextUrl' ? true : false)
|
if (entity._ == 'messageEntityTextUrl') {
|
||||||
|
url = entity.url
|
||||||
|
url = wrapUrl(url, true)
|
||||||
|
inner = wrapRichNestedText(entityText, entity.nested, options)
|
||||||
|
} else {
|
||||||
|
url = wrapUrl(entityText, false)
|
||||||
|
inner = encodeEntities(replaceUrlEncodings(entityText))
|
||||||
|
}
|
||||||
html.push(
|
html.push(
|
||||||
'<a href="',
|
'<a href="',
|
||||||
encodeEntities(url),
|
encodeEntities(url),
|
||||||
'" target="_blank" rel="noopener noreferrer">',
|
'" target="_blank" rel="noopener noreferrer">',
|
||||||
wrapRichNestedText(entityText, entity.nested, options),
|
inner,
|
||||||
'</a>'
|
'</a>'
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
@ -1867,6 +1874,16 @@ angular.module('izhukov.utils', [])
|
|||||||
return url
|
return url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replaceUrlEncodings(urlWithEncoded) {
|
||||||
|
return urlWithEncoded.replace(/(%[A-Z\d]{2})+/g, function (str) {
|
||||||
|
try {
|
||||||
|
return decodeURIComponent(str);
|
||||||
|
} catch (e) {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function wrapPlainText (text, options) {
|
function wrapPlainText (text, options) {
|
||||||
if (emojiSupported) {
|
if (emojiSupported) {
|
||||||
return text
|
return text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user