mirror of
https://github.com/appwrite/console.git
synced 2026-04-07 19:17:46 +00:00
Handle TLDs with multiple dots
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { Link } from '$lib/elements';
|
||||
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
|
||||
import { getSubdomain } from '$lib/helpers/tlds';
|
||||
import {
|
||||
Badge,
|
||||
Layout,
|
||||
@@ -15,7 +16,7 @@
|
||||
export let verified: boolean | undefined = undefined;
|
||||
export let ruleStatus: string | undefined = undefined;
|
||||
|
||||
let subdomain = domain.split('.').slice(0, -2).join('.');
|
||||
let subdomain = getSubdomain(domain);
|
||||
</script>
|
||||
|
||||
<Layout.Stack gap="xl">
|
||||
@@ -52,7 +53,7 @@
|
||||
</svelte:fragment>
|
||||
<Table.Row.Base {root}>
|
||||
<Table.Cell {root}>CNAME</Table.Cell>
|
||||
<Table.Cell {root}>{subdomain}</Table.Cell>
|
||||
<Table.Cell {root}>{subdomain || '@'}</Table.Cell>
|
||||
<Table.Cell {root}>
|
||||
<InteractiveText
|
||||
variant="copy"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
} from '@appwrite.io/pink-svelte';
|
||||
import { regionalConsoleVariables } from '$routes/(console)/project-[region]-[project]/store';
|
||||
import { isCloud } from '$lib/system';
|
||||
|
||||
import { getSubdomain } from '$lib/helpers/tlds';
|
||||
export let domain: string;
|
||||
export let verified: boolean | undefined = undefined;
|
||||
export let variant: 'cname' | 'a' | 'aaaa';
|
||||
@@ -20,7 +20,7 @@
|
||||
export let onNavigateToA: () => void = () => {};
|
||||
export let onNavigateToAAAA: () => void = () => {};
|
||||
|
||||
let subdomain = domain?.split('.')?.slice(0, -2)?.join('.');
|
||||
let subdomain = getSubdomain(domain);
|
||||
|
||||
const aTabVisible =
|
||||
!isCloud &&
|
||||
|
||||
+11
-2
@@ -4,7 +4,7 @@ import { parse } from 'tldts';
|
||||
* Returns the apex/root domain from a full domain string.
|
||||
*/
|
||||
export function getApexDomain(domain: string): string | null {
|
||||
return parse(domain).domain;
|
||||
return parse(domain, { allowPrivateDomains: true }).domain;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -13,8 +13,17 @@ export function getApexDomain(domain: string): string | null {
|
||||
export function isASubdomain(domain: string | null): boolean {
|
||||
if (!domain) return false;
|
||||
|
||||
const { domain: apex, subdomain } = parse(domain);
|
||||
const { domain: apex, subdomain } = parse(domain, { allowPrivateDomains: true });
|
||||
if (!apex) return false;
|
||||
|
||||
return !!subdomain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the subdomain part from a full domain string.
|
||||
*/
|
||||
export function getSubdomain(domain: string): string {
|
||||
if (!domain) return '';
|
||||
|
||||
return parse(domain, { allowPrivateDomains: true }).subdomain || '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user