Fixed // and overeager nested linking.

This commit is contained in:
flash 2025-05-19 00:51:00 +00:00
parent 40d1d585b6
commit c8edae09ba
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E

View file

@ -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;
}