export const transformLinks = (html: string) => {
    // Regex to match https://specificdomain.com/?page_id= followed by numbers
    // Using a more specific pattern to avoid matching other domains
    const regex = /(https?:\/\/)?(www\.)?new.jkhsakha\.ru\/(?!wp-content)(\/[^\s"']*)/g

    // Replace only the specific domain links with relative paths
    return html.replace(regex, '$3');
};

export function toRelativePath(input: string): string {
    try {
        // Handles absolute URLs
        const url = new URL(input);
        return url.pathname + url.search + url.hash;
    } catch {
        // Already relative (or invalid URL)
        if (input.startsWith('/')) return input;
        return '/' + input;
    }
}