Test cases from http://publicsuffix.org/list/test.txt
These cases run live, so show current state of play wrt to the public suffix list at Mozilla.
Note there are five test cases marked 'FAIL
' (at last time of running!). These are all subdomains of the 'example
' tld or 'example.com
'.
In fact, these are correctly passed by the catch all rule '*
', so the code is correct wrt to the published specification at http://publicsuffix.org/list/ (see rule 2). The writer of the test cases (Rob Stradling) probably had a special case in his code to reject all domains with 'example
' or 'example.com
' as suffix (quite reaosnably).
This implementation does not do this, but does set a PUBLIC_SUFFIX_EXAMPLE_FLAG
bit to the $flag
return result. See marked entires in the test list.
Cached Public Suffix Database
Reloaded database: 15767 lines and parsed 9751 rules in 0 seconds.
Running test cases
OK checkPublicSuffix( '', '' ) OK checkPublicSuffix( 'COM', '' ) OK checkPublicSuffix( 'example.COM', 'example.com' ) OK checkPublicSuffix( 'WwW.example.COM', 'example.com' ) OK checkPublicSuffix( '.com', '' ) OK checkPublicSuffix( '.example', '' ) PUBLIC_SUFFIX_EXAMPLE_FLAG set FAIL checkPublicSuffix( '.example.com', '' ) got 'example.com' FAIL checkPublicSuffix( '.example.example', '' ) got 'example.example' PUBLIC_SUFFIX_EXAMPLE_FLAG set OK checkPublicSuffix( 'example', '' ) PUBLIC_SUFFIX_EXAMPLE_FLAG set FAIL checkPublicSuffix( 'example.example', '' ) got 'example.example' PUBLIC_SUFFIX_EXAMPLE_FLAG set FAIL checkPublicSuffix( 'b.example.example', '' ) got 'example.example' PUBLIC_SUFFIX_EXAMPLE_FLAG set FAIL checkPublicSuffix( 'a.b.example.example', '' ) got 'example.example' PUBLIC_SUFFIX_EXAMPLE_FLAG set OK checkPublicSuffix( 'biz', '' ) OK checkPublicSuffix( 'domain.biz', 'domain.biz' ) OK checkPublicSuffix( 'b.domain.biz', 'domain.biz' ) OK checkPublicSuffix( 'a.b.domain.biz', 'domain.biz' ) OK checkPublicSuffix( 'com', '' ) OK checkPublicSuffix( 'example.com', 'example.com' ) OK checkPublicSuffix( 'b.example.com', 'example.com' ) OK checkPublicSuffix( 'a.b.example.com', 'example.com' ) OK checkPublicSuffix( 'uk.com', '' ) OK checkPublicSuffix( 'example.uk.com', 'example.uk.com' ) OK checkPublicSuffix( 'b.example.uk.com', 'example.uk.com' ) OK checkPublicSuffix( 'a.b.example.uk.com', 'example.uk.com' ) OK checkPublicSuffix( 'test.ac', 'test.ac' ) OK checkPublicSuffix( 'cy', '' ) FAIL checkPublicSuffix( 'c.cy', '' ) got 'c.cy' FAIL checkPublicSuffix( 'b.c.cy', 'b.c.cy' ) got 'c.cy' FAIL checkPublicSuffix( 'a.b.c.cy', 'b.c.cy' ) got 'c.cy' OK checkPublicSuffix( 'jp', '' ) OK checkPublicSuffix( 'test.jp', 'test.jp' ) OK checkPublicSuffix( 'www.test.jp', 'test.jp' ) OK checkPublicSuffix( 'ac.jp', '' ) OK checkPublicSuffix( 'test.ac.jp', 'test.ac.jp' ) OK checkPublicSuffix( 'www.test.ac.jp', 'test.ac.jp' ) OK checkPublicSuffix( 'kyoto.jp', '' ) FAIL checkPublicSuffix( 'c.kyoto.jp', '' ) got 'c.kyoto.jp' FAIL checkPublicSuffix( 'b.c.kyoto.jp', 'b.c.kyoto.jp' ) got 'c.kyoto.jp' FAIL checkPublicSuffix( 'a.b.c.kyoto.jp', 'b.c.kyoto.jp' ) got 'c.kyoto.jp' OK checkPublicSuffix( 'pref.kyoto.jp', 'pref.kyoto.jp' ) OK checkPublicSuffix( 'www.pref.kyoto.jp', 'pref.kyoto.jp' ) OK checkPublicSuffix( 'city.kyoto.jp', 'city.kyoto.jp' ) OK checkPublicSuffix( 'www.city.kyoto.jp', 'city.kyoto.jp' ) OK checkPublicSuffix( 'om', '' ) FAIL checkPublicSuffix( 'test.om', '' ) got 'test.om' FAIL checkPublicSuffix( 'b.test.om', 'b.test.om' ) got 'test.om' FAIL checkPublicSuffix( 'a.b.test.om', 'b.test.om' ) got 'test.om' OK checkPublicSuffix( 'songfest.om', 'songfest.om' ) OK checkPublicSuffix( 'www.songfest.om', 'songfest.om' ) OK checkPublicSuffix( 'us', '' ) OK checkPublicSuffix( 'test.us', 'test.us' ) OK checkPublicSuffix( 'www.test.us', 'test.us' ) OK checkPublicSuffix( 'ak.us', '' ) OK checkPublicSuffix( 'test.ak.us', 'test.ak.us' ) OK checkPublicSuffix( 'www.test.ak.us', 'test.ak.us' ) OK checkPublicSuffix( 'k12.ak.us', '' ) OK checkPublicSuffix( 'test.k12.ak.us', 'test.k12.ak.us' ) OK checkPublicSuffix( 'www.test.k12.ak.us', 'test.k12.ak.us' )