2018-07-08 15:02:28 +00:00
|
|
|
import { DomainExtractor } from "./DomainExtractor";
|
2017-10-07 16:37:08 +00:00
|
|
|
import Assert = require("assert");
|
|
|
|
|
2019-03-18 08:27:41 +00:00
|
|
|
describe("shared/DomainExtractor", function () {
|
2017-10-07 16:37:08 +00:00
|
|
|
describe("test fromUrl", function () {
|
|
|
|
it("should return domain from https url", function () {
|
|
|
|
const domain = DomainExtractor.fromUrl("https://www.example.com/test/abc");
|
|
|
|
Assert.equal(domain, "www.example.com");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return domain from http url", function () {
|
|
|
|
const domain = DomainExtractor.fromUrl("http://www.example.com/test/abc");
|
|
|
|
Assert.equal(domain, "www.example.com");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return domain when url contains port", function () {
|
|
|
|
const domain = DomainExtractor.fromUrl("https://www.example.com:8080/test/abc");
|
|
|
|
Assert.equal(domain, "www.example.com");
|
|
|
|
});
|
2018-10-27 16:18:25 +00:00
|
|
|
|
|
|
|
it("should return domain when url contains redirect param", function () {
|
|
|
|
const domain0 = DomainExtractor.fromUrl("https://www.example.com:8080/test/abc?rd=https://cool.test.com");
|
|
|
|
Assert.equal(domain0, "www.example.com");
|
|
|
|
|
|
|
|
const domain1 = DomainExtractor.fromUrl("https://login.example.com:8080/?rd=https://public.example.com:8080/");
|
|
|
|
Assert.equal(domain1, "login.example.com");
|
|
|
|
|
2019-03-03 22:51:52 +00:00
|
|
|
const domain2 = DomainExtractor.fromUrl("https://singlefactor.example.com:8080/secret.html");
|
|
|
|
Assert.equal(domain2, "singlefactor.example.com");
|
2018-10-27 16:18:25 +00:00
|
|
|
});
|
2017-10-07 16:37:08 +00:00
|
|
|
});
|
|
|
|
});
|