test_psl.txt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Any copyright is dedicated to the Public Domain.
  2. // https://creativecommons.org/publicdomain/zero/1.0/
  3. // null input.
  4. checkPublicSuffix(null, null);
  5. // Mixed case.
  6. checkPublicSuffix('COM', null);
  7. checkPublicSuffix('example.COM', 'example.com');
  8. checkPublicSuffix('WwW.example.COM', 'example.com');
  9. // Leading dot.
  10. checkPublicSuffix('.com', null);
  11. checkPublicSuffix('.example', null);
  12. checkPublicSuffix('.example.com', null);
  13. checkPublicSuffix('.example.example', null);
  14. // Unlisted TLD.
  15. checkPublicSuffix('example', null);
  16. checkPublicSuffix('example.example', 'example.example');
  17. checkPublicSuffix('b.example.example', 'example.example');
  18. checkPublicSuffix('a.b.example.example', 'example.example');
  19. // Listed, but non-Internet, TLD.
  20. //checkPublicSuffix('local', null);
  21. //checkPublicSuffix('example.local', null);
  22. //checkPublicSuffix('b.example.local', null);
  23. //checkPublicSuffix('a.b.example.local', null);
  24. // TLD with only 1 rule.
  25. checkPublicSuffix('biz', null);
  26. checkPublicSuffix('domain.biz', 'domain.biz');
  27. checkPublicSuffix('b.domain.biz', 'domain.biz');
  28. checkPublicSuffix('a.b.domain.biz', 'domain.biz');
  29. // TLD with some 2-level rules.
  30. checkPublicSuffix('com', null);
  31. checkPublicSuffix('example.com', 'example.com');
  32. checkPublicSuffix('b.example.com', 'example.com');
  33. checkPublicSuffix('a.b.example.com', 'example.com');
  34. checkPublicSuffix('uk.com', null);
  35. checkPublicSuffix('example.uk.com', 'example.uk.com');
  36. checkPublicSuffix('b.example.uk.com', 'example.uk.com');
  37. checkPublicSuffix('a.b.example.uk.com', 'example.uk.com');
  38. checkPublicSuffix('test.ac', 'test.ac');
  39. // TLD with only 1 (wildcard) rule.
  40. checkPublicSuffix('mm', null);
  41. checkPublicSuffix('c.mm', null);
  42. checkPublicSuffix('b.c.mm', 'b.c.mm');
  43. checkPublicSuffix('a.b.c.mm', 'b.c.mm');
  44. // More complex TLD.
  45. checkPublicSuffix('jp', null);
  46. checkPublicSuffix('test.jp', 'test.jp');
  47. checkPublicSuffix('www.test.jp', 'test.jp');
  48. checkPublicSuffix('ac.jp', null);
  49. checkPublicSuffix('test.ac.jp', 'test.ac.jp');
  50. checkPublicSuffix('www.test.ac.jp', 'test.ac.jp');
  51. checkPublicSuffix('kyoto.jp', null);
  52. checkPublicSuffix('test.kyoto.jp', 'test.kyoto.jp');
  53. checkPublicSuffix('ide.kyoto.jp', null);
  54. checkPublicSuffix('b.ide.kyoto.jp', 'b.ide.kyoto.jp');
  55. checkPublicSuffix('a.b.ide.kyoto.jp', 'b.ide.kyoto.jp');
  56. checkPublicSuffix('c.kobe.jp', null);
  57. checkPublicSuffix('b.c.kobe.jp', 'b.c.kobe.jp');
  58. checkPublicSuffix('a.b.c.kobe.jp', 'b.c.kobe.jp');
  59. checkPublicSuffix('city.kobe.jp', 'city.kobe.jp');
  60. checkPublicSuffix('www.city.kobe.jp', 'city.kobe.jp');
  61. // TLD with a wildcard rule and exceptions.
  62. checkPublicSuffix('ck', null);
  63. checkPublicSuffix('test.ck', null);
  64. checkPublicSuffix('b.test.ck', 'b.test.ck');
  65. checkPublicSuffix('a.b.test.ck', 'b.test.ck');
  66. checkPublicSuffix('www.ck', 'www.ck');
  67. checkPublicSuffix('www.www.ck', 'www.ck');
  68. // US K12.
  69. checkPublicSuffix('us', null);
  70. checkPublicSuffix('test.us', 'test.us');
  71. checkPublicSuffix('www.test.us', 'test.us');
  72. checkPublicSuffix('ak.us', null);
  73. checkPublicSuffix('test.ak.us', 'test.ak.us');
  74. checkPublicSuffix('www.test.ak.us', 'test.ak.us');
  75. checkPublicSuffix('k12.ak.us', null);
  76. checkPublicSuffix('test.k12.ak.us', 'test.k12.ak.us');
  77. checkPublicSuffix('www.test.k12.ak.us', 'test.k12.ak.us');
  78. // IDN labels.
  79. checkPublicSuffix('食狮.com.cn', '食狮.com.cn');
  80. checkPublicSuffix('食狮.公司.cn', '食狮.公司.cn');
  81. checkPublicSuffix('www.食狮.公司.cn', '食狮.公司.cn');
  82. checkPublicSuffix('shishi.公司.cn', 'shishi.公司.cn');
  83. checkPublicSuffix('公司.cn', null);
  84. checkPublicSuffix('食狮.中国', '食狮.中国');
  85. checkPublicSuffix('www.食狮.中国', '食狮.中国');
  86. checkPublicSuffix('shishi.中国', 'shishi.中国');
  87. checkPublicSuffix('中国', null);
  88. // Same as above, but punycoded.
  89. checkPublicSuffix('xn--85x722f.com.cn', 'xn--85x722f.com.cn');
  90. checkPublicSuffix('xn--85x722f.xn--55qx5d.cn', 'xn--85x722f.xn--55qx5d.cn');
  91. checkPublicSuffix('www.xn--85x722f.xn--55qx5d.cn', 'xn--85x722f.xn--55qx5d.cn');
  92. checkPublicSuffix('shishi.xn--55qx5d.cn', 'shishi.xn--55qx5d.cn');
  93. checkPublicSuffix('xn--55qx5d.cn', null);
  94. checkPublicSuffix('xn--85x722f.xn--fiqs8s', 'xn--85x722f.xn--fiqs8s');
  95. checkPublicSuffix('www.xn--85x722f.xn--fiqs8s', 'xn--85x722f.xn--fiqs8s');
  96. checkPublicSuffix('shishi.xn--fiqs8s', 'shishi.xn--fiqs8s');
  97. checkPublicSuffix('xn--fiqs8s', null);