Skip to content

Commit

Permalink
add public suffix support, remove 2 underscores from txt
Browse files Browse the repository at this point in the history
  • Loading branch information
istarkov committed Sep 20, 2024
1 parent ffa7147 commit 29c3d1a
Show file tree
Hide file tree
Showing 3 changed files with 5,112 additions and 13 deletions.
39 changes: 39 additions & 0 deletions apps/builder/app/builder/features/topbar/cname.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { describe, test, expect } from "@jest/globals";

import { extractCname } from "./cname";

describe("extractCname from ordinary domains", () => {
test('should return "@" for top level like domains', () => {
expect(extractCname("example")).toBe("@");
});

test('should return "@" for root level domains', () => {
expect(extractCname("example.com")).toBe("@");
});

test("should return the subdomain", () => {
expect(extractCname("sub.example.com")).toBe("sub");
});

test("should return all subdomains", () => {
expect(extractCname("sub.sub.example.com")).toBe("sub.sub");
});
});

describe("extractCname from public suffix domains", () => {
test('should return "@"', () => {
expect(extractCname("co.za")).toBe("@");
});

test('should return "@"', () => {
expect(extractCname("example.co.za")).toBe("@");
});

test("should return all the subdomain", () => {
expect(extractCname("sub.example.co.za")).toBe("sub");
});

test("should handle domains with multiple public suffixes correctly", () => {
expect(extractCname("sub.sub.example.co.za")).toBe("sub.sub");
});
});
Loading

0 comments on commit 29c3d1a

Please sign in to comment.