domain

package module
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 18

README

domain

GoDoc Version Build Status Go Report Card Codecov

Simple tools for manipulating Domain Names

Documentation

Overview

Package domain contains some nifty tools for manipulating domains and domain names.

Index

Constants

View Source
const ProtocolHTTP = "http://"

ProtocolHTTP is the HTTP protocol string

View Source
const ProtocolHTTPS = "https://"

ProtocolHTTPS is the HTTPS protocol string

Variables

This section is empty.

Functions

func AddProtocol

func AddProtocol(url string) string

AddProtocol adds a protocol to a URL if it does not already exist. Local domains use http:// and all other domains use https://

func HasProtocol added in v0.0.2

func HasProtocol(url string) bool

HasProtocol returns TRUE if the provided URL includes a protocol string

func Host added in v0.2.10

func Host(url string) string

Host returns the protocol and hostname

func Hostname added in v0.2.7

func Hostname(value string) string

Hostname returns ONLY the hostname, removing the protocol, port, path, and querystring from a hostname

func IsLocalhost

func IsLocalhost(hostname string) bool

IsLocalhost returns TRUE if the hostname is a local domain

func IsValidHostname added in v0.2.0

func IsValidHostname(hostname string) bool

func NameOnly

func NameOnly(value string) string

NameOnly removes the protocol and port from a hostname deprecated: Use Hostname instead

func NotLocalhost added in v0.1.0

func NotLocalhost(hostname string) bool

NotLocalhost returns TRUE if the hostname is NOT a local domain

func NotValidHostname added in v0.2.0

func NotValidHostname(hostname string) bool

func PathAndQuery added in v0.2.12

func PathAndQuery(value string) string

PathAndQuery removes the protocol, hostname, and port from a URL, returning only the path and querystring.

func Protocol

func Protocol(hostname string) string

Protocol returns the protocol to use for a given hostname. Local domains return `http://`, while all other domains return `https://`

func TrimHostname added in v0.2.11

func TrimHostname(url string) string

TrimHostname is an alias for PathAndQuery deprecated: Use PathAndQuery instead

func TrueHostname added in v0.2.10

func TrueHostname(request *http.Request) string

TrueHostname returns the host name from the request, accounting for proxy headers (like X-Forwarded-Host).

Types

This section is empty.

Jump to

Keyboard shortcuts

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