All Projects → danesparza → Domainname Parser

danesparza / Domainname Parser

Licence: mit
🏬 .NET domain name parsing library (uses publicsuffix.org)

Labels

Projects that are alternatives of or similar to Domainname Parser

Neon
🍸 Encodes and decodes NEON file format.
Stars: ✭ 674 (+2074.19%)
Mutual labels:  parsing
Rust Peg
Parsing Expression Grammar (PEG) parser generator for Rust
Stars: ✭ 836 (+2596.77%)
Mutual labels:  parsing
Samovar
Stars: ✭ 23 (-25.81%)
Mutual labels:  parsing
Meriyah
A 100% compliant, self-hosted javascript parser - https://meriyah.github.io/meriyah
Stars: ✭ 690 (+2125.81%)
Mutual labels:  parsing
M3u8
Parser and generator of M3U8-playlists for Apple HLS. Library for Go language. 🎦
Stars: ✭ 800 (+2480.65%)
Mutual labels:  parsing
Feedkit
An RSS, Atom and JSON Feed parser written in Swift
Stars: ✭ 895 (+2787.1%)
Mutual labels:  parsing
Rjsx Mode
A JSX major mode for Emacs
Stars: ✭ 604 (+1848.39%)
Mutual labels:  parsing
Got Reload
Reload Go code in a running process at function/method level granularity, using Yaegi
Stars: ✭ 29 (-6.45%)
Mutual labels:  parsing
Readr
Read flat files (csv, tsv, fwf) into R
Stars: ✭ 821 (+2548.39%)
Mutual labels:  parsing
Forma
Typespec based parsing of JSON-like data for Elixir
Stars: ✭ 23 (-25.81%)
Mutual labels:  parsing
Phonelib
Ruby gem for phone validation and formatting using google libphonenumber library data
Stars: ✭ 731 (+2258.06%)
Mutual labels:  parsing
Ason
[DEPRECATED]: Prefer Moshi, Jackson, Gson, or LoganSquare
Stars: ✭ 777 (+2406.45%)
Mutual labels:  parsing
Moment.php
Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Stars: ✭ 900 (+2803.23%)
Mutual labels:  parsing
Pydantic
Data parsing and validation using Python type hints
Stars: ✭ 8,362 (+26874.19%)
Mutual labels:  parsing
Probtopdf
Turn online textbook into Exam-friendly, offline, searchable PDF
Stars: ✭ 27 (-12.9%)
Mutual labels:  parsing
Owl
A parser generator for visibly pushdown languages.
Stars: ✭ 645 (+1980.65%)
Mutual labels:  parsing
Fuzi
A fast & lightweight XML & HTML parser in Swift with XPath & CSS support
Stars: ✭ 894 (+2783.87%)
Mutual labels:  parsing
Errorstacks
Tiny library to parse error stack traces
Stars: ✭ 29 (-6.45%)
Mutual labels:  parsing
Comby
A tool for structural code search and replace that supports ~every language.
Stars: ✭ 912 (+2841.94%)
Mutual labels:  parsing
Jkt
Simple helper to parse JSON based on independent schema
Stars: ✭ 22 (-29.03%)
Mutual labels:  parsing

domainname-parser Build status NuGet

.NET domain name parsing library (uses http://publicsuffix.org rules)

Overview

A domain name has 3 major parts:

  • The top level domain, or TLD (like .com, .net, .info)
  • The domain name, or SLD (like google, microsoft, ebay)
  • The subdomain (like www, photos)

Parsing a domain name into it's 3 major parts sounds easy, but is no trivial task. What happens when you come across hosts like test.co.uk? What about hosts like www.parliament.uk?

From http://publicsuffix.org :

"Since there is no algorithmic method of finding the highest level at which a domain may be registered for a particular top-level domain (the policies differ with each registry), the only method is to create a list. This is the aim of the Public Suffix List."

The domain name parsing component uses the list of rules at www.publicsuffix.org to parse a domain name into 3 component parts.

There are 3 types of rules: 'Normal' domain rules, 'Wildcard' rules, and 'Exception' rules.

Quick Start

Download the latest release from the NuGet repository

Install-Package domainname-parser

Download the latest rules file from https://publicsuffix.org/list/ and configure your app.config to point to the rules file you just downloaded (see the sample app.config)

Example

Using the component is simple. Just use the constructor or the static TryParse method and pass in the complete host name string. The component will return the parsed domain in a DomainName component. It's as simple as that:

// Try parsing a 'wildcard' domain 
if (DomainName.TryParse("photos.verybritish.co.uk", out outDomain)) 
{ 
  // The domain should be parsed as 'verybritish' 
  Assert.AreEqual("verybritish", outDomain.Domain);
  
  // The TLD is 'co.uk' 
  Assert.AreEqual("co.uk", outDomain.TLD);
  
  // The SLD is just an alias for 'Domain': 
  Assert.AreEqual(outDomain.Domain, outDomain.SLD);
  
  // The subdomain is everything else to the left of the domain: 
  Assert.AreEqual("photos", outDomain.SubDomain); 
} 
else 
{ 
  Debug.WriteLine("Apparently, we couldn't parse photos.verybritish.co.uk"); 
}

Where can I get the latest rules list?

You can download the latest rules from the Public Suffix site: http://publicsuffix.org/list/

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].