pslr

A focused, spec-complete implementation of the Public Suffix List (PSL) for R. pslr bundles a reproducible, pinned PSL snapshot and implements the official prevailing-rule algorithm to answer public-suffix (eTLD) and registrable-domain (eTLD+1) queries.

Installation

Install from GitHub:

# install.packages("pak")
pak::pak("bart-turczynski/pslr")

pslr depends on punycoder, which is installed automatically from CRAN.

Usage

library(pslr)

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

# ICANN vs PRIVATE sections
public_suffix("user.github.io")                    #> "github.io"
public_suffix("user.github.io", section = "icann") #> "io"

# Explicit membership vs the implicit default rule
is_public_suffix("madeuptld")                  #> TRUE  (implicit "*")
is_public_suffix("madeuptld", unknown = "na")  #> NA    (explicit only)

# Split a host, or inspect the prevailing rule
suffix_extract("blog.user.github.io")
public_suffix_rule("a.b.kobe.jp")

See vignette("introduction", package = "pslr") for the full tour: section choice, the unknown-suffix policy, IDN output, terminal dots, refresh and activation, reproducibility, and security notes.

Reproducibility

A result depends on both which list answered and how hosts were normalized. psl_version() reports the active-list provenance plus the runtime normalization identifiers; record it alongside reproducibility-sensitive output.

Development

Install dependencies plus the dev tooling used by the checks:

Rscript -e 'pak::local_install_deps(dependencies = TRUE)'

Run the same verification CI runs (lint + R CMD check --as-cran):

Rscript -e 'lints <- lintr::lint_package(); if (length(lints)) { print(lints); quit(status = 1) }' && Rscript -e 'rcmdcheck::rcmdcheck(args = "--as-cran", error_on = "warning")'

R CMD check runs the testthat and cucumber specs, so the behaviour specs are verified as part of the check. A non-CRAN performance benchmark and its release gate live in bench/benchmark.R; recorded reference results are in docs/benchmarks.md.

Project layout

License

Package code is MIT licensed. The bundled Public Suffix List data (inst/extdata/) is distributed under the Mozilla Public License 2.0; see inst/NOTICE and inst/extdata/PSL-LICENSE.