## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(pslr)

## -----------------------------------------------------------------------------
public_suffix("www.example.co.uk")
registrable_domain("www.example.co.uk")

## -----------------------------------------------------------------------------
public_suffix("a.b.kobe.jp") # a wildcard match under kobe.jp
public_suffix("city.kobe.jp") # an exception match under kobe.jp

## -----------------------------------------------------------------------------
# github.io is a PRIVATE rule sitting under the ICANN suffix io.
public_suffix("user.github.io", section = "all") # default scope, both sections
public_suffix("user.github.io", section = "icann") # the ICANN rule for io
public_suffix("user.github.io", section = "private")

## -----------------------------------------------------------------------------
public_suffix("example.com", section = "private")

## -----------------------------------------------------------------------------
public_suffix("example.madeuptld") # default rule
public_suffix("example.madeuptld", unknown = "na") # explicit-only

## -----------------------------------------------------------------------------
is_public_suffix("co.uk")
is_public_suffix("madeuptld") # TRUE via the implicit default rule
is_public_suffix("madeuptld", unknown = "na") # explicit membership only

## -----------------------------------------------------------------------------
public_suffix("example.рф") # ASCII A-label by default
public_suffix("example.рф", output = "unicode") # decoded to Unicode
public_suffix("example.xn--p1ai") # the A-label spelling agrees

## -----------------------------------------------------------------------------
public_suffix("www.example.com.")
registrable_domain("www.example.com.")

## -----------------------------------------------------------------------------
suffix_extract("blog.user.github.io")
public_suffix_rule(c("www.ck", "a.b.kobe.jp", "example.madeuptld"))

## ----eval = FALSE-------------------------------------------------------------
# # Download and validate a fresh list into the user cache, then activate it:
# psl_refresh(activate = TRUE)
# 
# # Switch the active list for this session:
# psl_use("cache") # the latest refreshed snapshot
# psl_use("bundled") # back to the shipped snapshot
# psl_use("path", path = "my_list.dat") # a custom file

## -----------------------------------------------------------------------------
psl_version()

## -----------------------------------------------------------------------------
nrow(psl_rules("icann"))
head(psl_rules("private"), 3)

