filterutil

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package filterutil contains helper functions used by urlfilter

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractHostname

func ExtractHostname(url string) string

ExtractHostname -- quickly retrieves hostname from an URL

func FastHash added in v0.15.0

func FastHash(str string) uint32

FastHash implements the djb2 hash algorithm.

TODO(e.burkov): Inspect all uses. Perhaps use maphash.

func FastHashBetween added in v0.15.0

func FastHashBetween(str string, begin, end int) uint32

FastHashBetween implements the djb2 hash algorithm.

func IsDomainName added in v0.12.0

func IsDomainName(name string) bool

IsDomainName - check if input string is a valid domain name Syntax: [label.]... label.label

Each label is 1 to 63 characters long, and may contain:

. ASCII letters a-z and A-Z
. digits 0-9
. hyphen ('-')

. labels cannot start or end with hyphens (RFC 952) . max length of ascii hostname including dots is 253 characters . TLD is >=2 characters . TLD is [a-zA-Z]+ or "xn--[a-zA-Z0-9]+"

func IsProbablyIP added in v0.17.0

func IsProbablyIP(s string) (ok bool)

IsProbablyIP returns true if s only contains characters that can be part of an IP address. It's needed to avoid unnecessary allocations when parsing with [netip.ParseAddr].

Types

This section is empty.

Jump to

Keyboard shortcuts

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