https://github.com/squeek502/lua-public_suffix_list
Lua interface to the Public Suffix List rules
https://github.com/squeek502/lua-public_suffix_list
lua public-suffix-list
Last synced: 2 months ago
JSON representation
Lua interface to the Public Suffix List rules
- Host: GitHub
- URL: https://github.com/squeek502/lua-public_suffix_list
- Owner: squeek502
- License: unlicense
- Created: 2018-07-17T06:15:06.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-15T02:15:46.000Z (over 6 years ago)
- Last Synced: 2025-01-29T12:32:41.586Z (4 months ago)
- Topics: lua, public-suffix-list
- Language: Lua
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
public_suffix_list
==================[](https://travis-ci.org/squeek502/lua-public_suffix_list)
Simple Lua interface to the [Public Suffix List](https://publicsuffix.org/) rules, intended to be used a building block for implementing the PSL domain parsing algorithm. New Luarocks builds are automatically created each month using the latest Public Suffix List.
```lua
local public_suffix_list = require('public_suffix_list')if public_suffix_list.exists('com') then
-- ...
end
```## Installation
With [Luarocks](https://luarocks.org):
```
luarocks install public_suffix_list
```## Generating
Note: `public_suffix_list.lua` is not checked into the repository. Instead, [`public_suffix_list.dat`](https://publicsuffix.org/list/public_suffix_list.dat) is parsed and converted into a Lua table that is then used to create `public_suffix_list.lua` (from `public_suffix_list.in.lua`).- Clone this repository
- Download `public_suffix_list.dat` from [here](https://publicsuffix.org/list/public_suffix_list.dat) or [here](https://raw.githubusercontent.com/publicsuffix/list/HEAD/public_suffix_list.dat)
- Run `lua generate.lua`## API Reference
### `public_suffix_list.exists(suffix)`
Checks if the suffix rule exists (can be any type). On success, returns `true`; otherwise, returns `false`.### `public_suffix_list.getType(suffix)`
Returns the type of the suffix rule (as a lowercase string) if it exists (e.g. `"icann"` or `"private"`); othwerwise, returns `nil, errmsg`.### `public_suffix_list.isICANN(suffix)`
Returns `true` if the suffix rule is delegated by ICANN; otherwise, returns `false`.### `public_suffix_list.isPrivate(suffix)`
Returns `true` if the suffix rule is submitted by a domain holder; otherwise, returns `false`.### `public_suffix_list.rules`
A table of `key, value` pairs where `key` is a suffix rule type (as a lowercase string, e.g. `"icann"`) and `value` is an array-like table of suffix rules.