mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-06-20 21:00:41 +00:00
25 lines
641 B
TypeScript
25 lines
641 B
TypeScript
import type { Cipher } from './types';
|
|
|
|
export function firstCipherUri(cipher: Cipher): string {
|
|
const uris = cipher.login?.uris || [];
|
|
for (const uri of uris) {
|
|
const raw = uri.decUri || uri.uri || '';
|
|
if (raw.trim()) return raw.trim();
|
|
}
|
|
return '';
|
|
}
|
|
|
|
export function hostFromUri(uri: string): string {
|
|
if (!uri.trim()) return '';
|
|
try {
|
|
const normalized = /^https?:\/\//i.test(uri) ? uri : `https://${uri}`;
|
|
return new URL(normalized).hostname || '';
|
|
} catch {
|
|
return '';
|
|
}
|
|
}
|
|
|
|
export function websiteIconUrl(host: string): string {
|
|
return `/icons/${encodeURIComponent(host)}/icon.png?fallback=404`;
|
|
}
|