Truncate MPD URLs in live-lists channel overview.
This commit is contained in:
parent
94bf98ded7
commit
b49a9144b2
1 changed files with 15 additions and 0 deletions
|
|
@ -74,6 +74,21 @@ function formFromChannel(c: LiveChannelRow): ChannelForm {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Korte preview in zender-overzicht (volledige URL via title/tooltip). */
|
||||||
|
function shortUrl(url: string, max = 42): string {
|
||||||
|
const s = url.trim();
|
||||||
|
if (s.length <= max) return s;
|
||||||
|
try {
|
||||||
|
const u = new URL(s);
|
||||||
|
const path = u.pathname.split("/").filter(Boolean).pop() ?? "";
|
||||||
|
const host = u.host.replace(/^www\./, "");
|
||||||
|
const tip = path ? `${host}/…/${path}` : host;
|
||||||
|
return tip.length <= max ? tip : `${tip.slice(0, max - 1)}…`;
|
||||||
|
} catch {
|
||||||
|
return `${s.slice(0, max - 1)}…`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function LiveListsPage() {
|
export default function LiveListsPage() {
|
||||||
useAuth();
|
useAuth();
|
||||||
const [lists, setLists] = useState<LiveListSummary[]>([]);
|
const [lists, setLists] = useState<LiveListSummary[]>([]);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue