isdomain

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2016 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

Documentation

Overview

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

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

Index

Constants

View Source
const DomainRegexpStr = "^([a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,}$"

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{}/* 725 elements not displayed */

TLDs is a set of TLDs, according to ICANN in 2014.

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