diff options
Diffstat (limited to 'vanilla/node_modules/tldts-core/src/subdomain.ts')
| -rw-r--r-- | vanilla/node_modules/tldts-core/src/subdomain.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/vanilla/node_modules/tldts-core/src/subdomain.ts b/vanilla/node_modules/tldts-core/src/subdomain.ts new file mode 100644 index 0000000..bbb9c97 --- /dev/null +++ b/vanilla/node_modules/tldts-core/src/subdomain.ts @@ -0,0 +1,11 @@ +/** + * Returns the subdomain of a hostname string + */ +export default function getSubdomain(hostname: string, domain: string): string { + // If `hostname` and `domain` are the same, then there is no sub-domain + if (domain.length === hostname.length) { + return ''; + } + + return hostname.slice(0, -domain.length - 1); +} |
