Fixed // and overeager nested linking.
This commit is contained in:
parent
40d1d585b6
commit
c8edae09ba
1 changed files with 7 additions and 3 deletions
|
@ -242,6 +242,9 @@ Umi.UI.Messages = (function() {
|
|||
let childNode = element.firstChild;
|
||||
while(childNode instanceof Node)
|
||||
try {
|
||||
if(childNode instanceof HTMLAnchorElement)
|
||||
continue;
|
||||
|
||||
if(childNode instanceof HTMLElement) {
|
||||
linkify(childNode);
|
||||
continue;
|
||||
|
@ -253,14 +256,15 @@ Umi.UI.Messages = (function() {
|
|||
let offset = 0;
|
||||
const parts = childNode.data.split(/([\p{White_Space}(){}\[\]<>'"]+)/u);
|
||||
for(const part of parts) {
|
||||
if(!part.startsWith('//') && !part.includes('://')) {
|
||||
const noProto = part.startsWith('//');
|
||||
if(!noProto && !part.includes('://')) {
|
||||
offset += part.length;
|
||||
continue;
|
||||
}
|
||||
|
||||
let url;
|
||||
try {
|
||||
url = new URL(part);
|
||||
url = new URL(noProto ? (location.protocol + part) : part);
|
||||
} catch(ex) {
|
||||
offset += part.length;
|
||||
continue;
|
||||
|
@ -276,7 +280,7 @@ Umi.UI.Messages = (function() {
|
|||
text = text.substring(0, text.length - 1);
|
||||
|
||||
if(text.length < part.length) {
|
||||
url = new URL(text);
|
||||
url = new URL(noProto ? (location.protocol + text) : text);
|
||||
offset += part.length - text.length;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue