urlutil

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package urlutil provides URL-related utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCleanPath

func GetCleanPath(u *url.URL) string

GetCleanPath returns cleaned u.Path. It is like path.Clean(u.Path) but does not remove the trailing slash.

func HasSameOrigin

func HasSameOrigin(u1 *url.URL, u2 *url.URL) bool

HasSameOrigin reports whether u1 and u2 have the same nonempty Scheme and Host. u1 and u2 are assumed to be absolute URLs with the http/https scheme. Nevertheless, HasSameOrigin returns false when either or both of them have empty Scheme or Host.

HasSameOrigin does not implement all the rules defined for "same origin" in HTML5 but yields the same result if u1 and u2 are both absolute URLs with the http/https scheme, barring one corner case: HasSameOrigin does not recognize the default port numbers, e.g. it reports https://example.com and https://example.com:443 have a "different origin."

func IsDir

func IsDir(u *url.URL) bool

IsDir reports whether u represents a directory. Specifically, IsDir returns true when u.Path ends with a slash ("/") or the last component of u.Path is either "." or "..".

func MustParse

func MustParse(rawurl string) *url.URL

MustParse is like url.Parse but panics on a parse error. It simplifies safe initialization of global variables holding parsed URLs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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