parseurl

package module
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

README

ParseURL

ParseURL is a simple wrapper that fixes some of the weird issues that the standard Golang 'url.Parse' function does.

Fixes things such as

  • "localhost:8080"
    • url.Parse: Host == "", Scheme == "localhost:8080"
  • "10.10.10.10/url/"
    • url.Parse: Returns an error <why?>
  • "localhost:"
    • url.Parse: Host == "localhost:" <doesn't strip the ':'>

This package adds in checks for invalid values returned by 'url.Parse' such as the Host field being empty. All non-standard errors wrap the error "ErrInvalidURL" to assist in indication of the error.

This library is a drop-in replacement for the "url.Parse" function. Just import "github.com/PurpleSec/parseurl" and go!

Documentation

Overview

Package parseurl is a simple wrapper that fixes some of the weird issues that the standard Golang 'url.Parse' function does.

Fixes things such as

  • "localhost:8080" url.Parse: Host == "", Scheme == "localhost:8080"
  • "10.10.10.10/url/" url.Parse: Returns an error <why?>
  • "localhost:" url.Parse: Host == "localhost:" <doesn't strip the ':'>

This package adds in checks for invalid values returned by 'url.Parse' such as the Host field being empty. All non-standard errors wrap the error "ErrInvalidURL" to assist in indication of the error.

This library is a drop-in replacement for the "url.Parse" function. Just import "github.com/PurpleSec/parseurl" and go!

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

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

Parse parses rawurl into a URL structure.

The rawurl may be relative (a path, without a host) or absolute (starting with a scheme). Trying to parse a hostname and path without a scheme is invalid but may not necessarily return an error, due to parsing ambiguities.

This function is a modified version of the standard 'url.Parse' function that will handle and fix any errors that occur during Parsing. This function also includes additional error checks that will prevent some common formatting issues from occuring without an error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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