isdomain

package
v0.0.0-...-8b9b725 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2019 License: MIT, MIT Imports: 2 Imported by: 0

README

go-is-domain

This package is dedicated to @whyrusleeping.

Docs: https://godoc.org/github.com/jbenet/go-is-domain

Check whether something is a domain.


import (
  isd "github.com/jbenet/go-is-domain"
)

isd.IsDomain("foo.com") // true
isd.IsDomain("foo.bar.com.") // true
isd.IsDomain("foo.bar.baz") // false

MIT Licensed

Updating TLDs

To update non-extended TLDs, IANA publishes, you can retrieve them from data.iana.org.

After retrieving the updated list, enter them into the file tlds-alpha-by-domain.txt. In order to update the TLDs map in tlds.go, you can run the gen.sh script which will generate the contents of a string -> bool map. After that, you'll want to replace the contents of the existing TLDs map, with the one that was generated and stored in formatted_tlds.txt

Documentation

Overview

Package isdomain package allows users to check whether strings represent domain names.

import (
	isd "github.com/ipsn/go-ipfs/gxlibs/github.com/jbenet/go-is-domain"
)

isd.IsDomain("foo.com") // true
isd.IsDomain("foo.bar.com.") // true
isd.IsDomain("foo.bar.baz") // false

Index

Constants

View Source
const DomainRegexpStr = "^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])(\\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9]))*$"

DomainRegexpStr is a regular expression string to validate domains.

Variables

View Source
var ExtendedTLDs = map[string]bool{
	"BIT":   true,
	"ONION": true,
}

ExtendedTLDs is a set of additional "TLDs", allowing decentralized name systems, like TOR and Namecoin.

View Source
var TLDs = map[string]bool{}/* 1532 elements not displayed */

Version 2019032100, Last Updated Thu Mar 21 07:07:01 2019 UTC

Functions

func IsDomain

func IsDomain(s string) bool

IsDomain returns whether given string is a domain. It first checks the TLD, and then uses a regular expression.

func IsExtendedTLD

func IsExtendedTLD(s string) bool

IsExtendedTLD returns whether the given string is a TLD (Top Level Domain), extended with a few other "TLDs": .bit, .onion

func IsICANNTLD

func IsICANNTLD(s string) bool

IsICANNTLD returns whether the given string is a TLD (Top Level Domain), according to ICANN. Well, really according to the TLDs listed in this package.

func IsTLD

func IsTLD(s string) bool

IsTLD returns whether the given string is a TLD (according to ICANN, or in the set of ExtendedTLDs listed in this package.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL