-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add public suffix support, remove 2 underscores from txt
- Loading branch information
Showing
3 changed files
with
5,112 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
}); | ||
}); |
Oops, something went wrong.