[Bug] LinkedText.vue crashes component render with uncaught TypeError: Invalid URL when compact=true receives malformed https:// substrings
发生了什么 / What happened
Summary
LinkedText.vue is rendered with compact in web/src/components/AccountsPanel.vue:2387, 2604, 2809 for account error/restriction messages. In web/src/components/LinkedText.vue:10-20:
const pieces = computed(() =>
props.text
.split(/(https:\/\/[^\s,。;))]+)/)
.filter(Boolean)
.map((piece) => ({ text: piece, url: piece.startsWith('https://') })),
)
function label(url: string): string {
if (!props.compact) return url
const parsed = new URL(url)
return parsed.host + parsed.pathname
}
Trigger & Consequence
The split regex matches malformed URLs or trailing punctuation such as "https://example.com", https://example.com:port, or https://[invalid. Because label(piece.text) is called directly inside the template without try/catch, new URL(url) throws an uncaught TypeError: Invalid URL and crashes rendering of the row/panel.
Suggested Fix
Wrap new URL(url) in try/catch and return url on failure:
function label(url: string): string {
if (!props.compact) return url
try {
const parsed = new URL(url)
return parsed.host + parsed.pathname
} catch {
return url
}
}
版本 / Version
v0.3.14
每人最多同时打开 3 个 Issue,这个 Issue 已自动关闭。请等已有的 Issue 处理完再提,或把内容补充到已有的 Issue 里。
Each user can have at most 3 open issues at a time, so this one was closed automatically. Please wait until your existing issues are resolved, or add this to one of them.