feat: add global sidebar links management and settings UI
This commit is contained in:
1 parent
3203577a9d
commit
f6f3c402cc
10 files changed
+463
-40
No files matched your search
@@ -0,0 +1,19 @@
|
||||
export function normalizeSidebarLink(link) {
|
||||
const label = typeof link?.label === "string" ? link.label.trim() : "";
|
||||
if (!label) throw new Error("Bitte einen Namen für den Link eingeben.");
|
||||
|
||||
const address = typeof link.url === "string" ? link.url.trim() : "";
|
||||
let url;
|
||||
if (/^https?:\/\//i.test(address)) {
|
||||
try {
|
||||
url = new URL(address);
|
||||
} catch {
|
||||
// Report malformed addresses with the same message as unsupported schemes.
|
||||
}
|
||||
}
|
||||
if (!url || url.username || url.password) {
|
||||
throw new Error("Bitte eine vollständige HTTP- oder HTTPS-Adresse ohne Zugangsdaten eingeben.");
|
||||
}
|
||||
|
||||
return { label, url: url.href };
|
||||
}
|
||||
Reference in new issue
Block a user