fix plc
This commit is contained in:
@@ -14,6 +14,33 @@ export function getPlc(): string {
|
||||
return networkConfig?.plc || 'https://plc.directory'
|
||||
}
|
||||
|
||||
// Get PLC URL based on PDS endpoint
|
||||
export function getPlcForPds(pds: string, networks: Record<string, { plc: string; bsky: string; web?: string }>): string {
|
||||
// Check if PDS matches any network
|
||||
for (const [_key, config] of Object.entries(networks)) {
|
||||
// Match by domain (e.g., "https://syu.is" or "https://bsky.syu.is")
|
||||
try {
|
||||
const pdsHost = new URL(pds).hostname
|
||||
const bskyHost = new URL(config.bsky).hostname
|
||||
// Check if PDS host matches network's bsky host
|
||||
if (pdsHost === bskyHost || pdsHost.endsWith('.' + bskyHost)) {
|
||||
return config.plc
|
||||
}
|
||||
// Also check web host if available
|
||||
if (config.web) {
|
||||
const webHost = new URL(config.web).hostname
|
||||
if (pdsHost === webHost || pdsHost.endsWith('.' + webHost)) {
|
||||
return config.plc
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
continue
|
||||
}
|
||||
}
|
||||
// Default to plc.directory
|
||||
return 'https://plc.directory'
|
||||
}
|
||||
|
||||
function getBsky(): string {
|
||||
return networkConfig?.bsky || 'https://public.api.bsky.app'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user