Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leetaogoooo/tldts
tldts is a Dart library to extract hostnames, domains, public suffixes, top-level domains and subdomains from URLs
https://github.com/leetaogoooo/tldts
Last synced: about 2 months ago
JSON representation
tldts is a Dart library to extract hostnames, domains, public suffixes, top-level domains and subdomains from URLs
- Host: GitHub
- URL: https://github.com/leetaogoooo/tldts
- Owner: LeetaoGoooo
- License: mit
- Created: 2024-06-22T02:52:06.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-06-22T02:52:50.000Z (7 months ago)
- Last Synced: 2024-10-12T06:21:17.760Z (3 months ago)
- Language: Dart
- Size: 54.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# tldts - Blazing Fast URL Parsing
`tldts` is a Dart library to extract hostnames, domains, public suffixes, top-level domains and subdomains from URLs, inspired by the [tldts](https://github.com/remusao/tldts) library for JavaScript.**Features**:
1. Handles both URLs and hostnames
2. Full Unicode/IDNA support
3. Support parsing email addresses
4. Detect IPv4 and IPv6 addresses
5. Continuously updated version of the public suffix list# Install
```dart
dart pub add tldts
```# Usage
```dart
import 'package:tldts/tldts.dart';
import 'package:test/test.dart';void main() {
test('parse url', () {
final result = parse(
"https://www.leetao.me/post/242/how-to-release-android-apk-without-sign-using-github-action");expect(result.domain, "leetao.me");
expect(result.domainWithoutSuffix, "leetao");
expect(result.hostname, "www.leetao.me");
// expect(result.isIcann, true); # TODO: some issues with this
expect(result.isIp, false);
expect(result.isPrivate, false);
expect(result.publicSuffix, "me");
expect(result.subdomain, "www");
});
}
```## Additional information
**tldts is still under development, so there are likely to be some bugs. Be carefully when using it**