persona-community-5/.pnpm-store/v3/files/62/81387420dd07da2bbbefdc05e02fa18e192f6d1cfa2698cb929fb14c1d9464e78ade0d1328699c6d86ef7fb87281a16bc1a92211de20e6bed1e81d859a9973
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

49 lines
1.1 KiB
Plaintext

import type { Region } from '../config/types';
let redoclyDomain = 'redocly.com';
export const DEFAULT_REGION = 'us';
export const DOMAINS = getDomains();
export const AVAILABLE_REGIONS = Object.keys(DOMAINS) as Region[];
export function getDomains() {
const domains: { [region in Region]: string } = {
us: 'redocly.com',
eu: 'eu.redocly.com',
};
// FIXME: temporary fix for our lab environments
const domain = redoclyDomain;
if (domain?.endsWith('.redocly.host')) {
domains[domain.split('.')[0] as Region] = domain;
}
if (domain === 'redoc.online') {
domains[domain as Region] = domain;
}
return domains;
}
export function setRedoclyDomain(domain: string) {
redoclyDomain = domain;
}
export function getRedoclyDomain(): string {
return redoclyDomain;
}
export function isRedoclyRegistryURL(link: string): boolean {
const domain = getRedoclyDomain() || DOMAINS[DEFAULT_REGION];
const legacyDomain = domain === 'redocly.com' ? 'redoc.ly' : domain;
if (
!link.startsWith(`https://api.${domain}/registry/`) &&
!link.startsWith(`https://api.${legacyDomain}/registry/`)
) {
return false;
}
return true;
}