string: add psl_suffix_is_known / psl_domain_is_known helpers

Add kumo.string.psl_suffix_is_known and kumo.string.psl_domain_is_known,
which report whether the resolved public suffix is explicitly listed in
Mozilla's Public Suffix List.

The psl crate applies a "fallback rule": a domain whose public suffix is
not in the list (e.g. `domain.invalid`) still resolves to a suffix, but
that suffix is not explicitly known. Existing kumo.string.psl_suffix /
psl_domain discard this information, so fallback-resolved suffixes are
indistinguishable from explicitly listed ones.

The new functions return `true` when the suffix is explicitly listed,
or `false` otherwise (fallback-resolved, or no public suffix at all).

closes: https://github.com/KumoCorp/kumomta/pull/592
This commit is contained in:
Umut Sahin Onder
2026-10-21 09:02:07 +01:00
committed by Wez Furlong
parent 47c1df231e
commit 41afc7914a
5 changed files with 117 additions and 0 deletions
@@ -0,0 +1,21 @@
# kumo.string.psl_domain_is_known
```lua
kumo.string.psl_domain_is_known(STRING)
```
{{since('dev')}}
Check whether the registrable domain's public suffix is explicitly listed in
Mozilla's [Public Suffix
List](https://publicsuffix.org/).
Returns `true` when the input is a registrable domain whose public suffix is
explicitly listed, or `false` when the suffix was derived from an unlisted
label, or when the input has no registrable domain.
```lua
assert(kumo.string.psl_domain_is_known 'www.example.com' == true)
assert(kumo.string.psl_domain_is_known 'domain.invalid' == false)
assert(kumo.string.psl_domain_is_known 'com' == false)
```
@@ -0,0 +1,18 @@
# kumo.string.psl_suffix_is_known
```lua
kumo.string.psl_suffix_is_known(STRING)
```
{{since('dev')}}
Check whether the public suffix is explicitly listed in Mozilla's [Public Suffix
List](https://publicsuffix.org/).
Returns `true` when the suffix is explicitly listed, or `false` when the suffix
was derived from an unlisted label, or when the input has no public suffix.
```lua
assert(kumo.string.psl_suffix_is_known 'www.example.com' == true)
assert(kumo.string.psl_suffix_is_known 'domain.invalid' == false)
```