urlparser

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package urlparser parses and validates URLs with support for wildcards. This is an internal package that provides custom URL parsing for the uncors project.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyHost   = errors.New("empty host")
	ErrEmptyPort   = errors.New("empty port")
	ErrInvalidHost = errors.New("invalid host")
	ErrEmptyURL    = errors.New("empty url")
)

Functions

func Parse

func Parse(rawURL string) (*url.URL, error)

Parse parses raw URL string into the net/url URL struct. It uses the url.Parse() internally, but it slightly changes its behavior:

  1. It forces the default scheme and port to http
  2. It favors absolute paths over relative ones, thus "example.com" is parsed into url.Host instead of url.Path.
  3. It lowercase's the Host (not only the Scheme).

func ParseWithDefaultScheme

func ParseWithDefaultScheme(rawURL string, scheme string) (*url.URL, error)

ParseWithDefaultScheme parses raw URL string with a custom default scheme. If the URL doesn't have a scheme, the provided scheme will be used. If scheme is empty, the URL will be parsed without a default scheme.

func SplitHostPort

func SplitHostPort(parsedURL *url.URL) (string, string, error)

SplitHostPort splits network address of the form "host:port" into host and port. Unlike net.SplitHostPort(), it doesn't remove brackets from [IPv6] host, and it accepts net/url.URL struct instead of a string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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