Parenthesis fixes.

This commit is contained in:
flash 2025-05-19 11:33:10 +00:00
parent 911bf2f934
commit c4872f1fc0
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E

View file

@ -254,8 +254,13 @@ Umi.UI.Messages = (function() {
continue;
let offset = 0;
const parts = childNode.data.split(/([\p{White_Space}(){}\[\]<>'"]+)/u);
for(const part of parts) {
const parts = childNode.data.split(/([\p{White_Space}{}\[\]<>'"]+)/u);
for(let part of parts) {
while(part.startsWith('(') && part.endsWith(')')) {
offset += 1;
part = part.substring(1, part.length - 1);
}
const noProto = part.startsWith('//');
if(!noProto && !part.includes('://')) {
offset += part.length;
@ -275,20 +280,20 @@ Umi.UI.Messages = (function() {
offset = 0;
}
let text = part;
while(!text.endsWith('/') && /\p{P}$/u.test(text))
text = text.substring(0, text.length - 1);
const length = part.length;
while(!part.endsWith('/') && /\p{Po}$/u.test(part))
part = part.substring(0, part.length - 1);
if(text.length < part.length) {
url = new URL(noProto ? (location.protocol + text) : text);
offset += part.length - text.length;
if(part.length < length) {
url = new URL(noProto ? (location.protocol + part) : part);
offset += length - part.length;
}
const replaceNode = childNode;
childNode = replaceNode.splitText(text.length);
childNode = replaceNode.splitText(part.length);
replaceNode.replaceWith(<a class="markup__link" href={url.toString()} target="_blank" rel="nofollow noreferrer noopener">
{decodeURI(text)}
{decodeURIComponent(part)}
</a>);
}
} finally {