public_suffix
3.0.0, released 6 years ago by an unverified publisher
A domain parser based on the Public Suffix List to identify root and suffix parts of URLs.
WASM-ready
What it does
Identifies public suffixes (TLDs), root domains, registrable domains, and subdomains from URLs. It supports punycode encoded URLs and custom rule lists.
AI-written summary of version 3.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to parse URLs to extract root domains or TLDs accurately using the Public Suffix List.
- You are working with punycoded domains and need both encoded and decoded forms.
Skip it when
- You do not want to manage or load suffix rule lists separately.
Strengths
- Supports custom rule lists and ICANN vs private rules.
- Handles punycode encoded URLs.
Weaknesses
- Does not bundle a default suffix list, requiring it to be loaded at runtime.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Requires loading the Public Suffix List file via assets or network and initializing DefaultSuffixRules or SuffixRules.
import 'package:public_suffix/public_suffix.dart';
main() {
var suffixListString = 'load the list into this string';
DefaultSuffixRules.initFromString(suffixListString);
var parsedUrl = PublicSuffix(urlString: 'https://www.komposten.github.io');
print(parsedUrl.suffix);
print(parsedUrl.root);
}