Fix URL truncation in CLI display components #5902 (#5925)

This commit is contained in:
fuyou
2025-08-18 13:26:34 +08:00
committed by GitHub
parent 133f0230c3
commit 7b03a64b85
4 changed files with 24 additions and 5 deletions

View File

@@ -22,10 +22,15 @@ interface RenderInlineProps {
}
const RenderInlineInternal: React.FC<RenderInlineProps> = ({ text }) => {
// Early return for plain text without markdown or URLs
if (!/[*_~`<[https?:]/.test(text)) {
return <Text>{text}</Text>;
}
const nodes: React.ReactNode[] = [];
let lastIndex = 0;
const inlineRegex =
/(\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|<u>.*?<\/u>)/g;
/(\*\*.*?\*\*|\*.*?\*|_.*?_|~~.*?~~|\[.*?\]\(.*?\)|`+.+?`+|<u>.*?<\/u>|https?:\/\/\S+)/g;
let match;
while ((match = inlineRegex.exec(text)) !== null) {
@@ -126,6 +131,12 @@ const RenderInlineInternal: React.FC<RenderInlineProps> = ({ text }) => {
)}
</Text>
);
} else if (fullMatch.match(/^https?:\/\//)) {
renderedNode = (
<Text key={key} color={Colors.AccentBlue}>
{fullMatch}
</Text>
);
}
} catch (e) {
console.error('Error parsing inline markdown part:', fullMatch, e);