Skip to content

statusmachine/urlidentification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

URL Identification

urlidentification is a library to help you identify what kind of URL your have.

It is based on RFC 3986's definitions for:

Example usage

package main

import "fmt"
import "net/url"
import "github.com/statusmachine/urlidentification"

func main() {
	absoluteUrl, _ := url.Parse("https://www.statusmachine.com/subdir/page.html")
	networkPathReference, _ := url.Parse("//www.statusmachine.com/subdir/page.html")
	relativeRefWithAbsPath, _ := url.Parse("/subdir/page.html")
	relativePathRef, _ := url.Parse("subdir/page.html")

	fmt.Println("is absolute url:", urlidentification.IsAbsoluteURL(absoluteUrl))
	fmt.Println("is network path reference:", urlidentification.IsNetworkPathReferenceURL(networkPathReference))
	fmt.Println("is relative reference with absolute path:", urlidentification.IsRelativeReferenceWithAbsolutePathURL(relativeRefWithAbsPath))
	fmt.Println("is relative path reference:", urlidentification.IsRelativePathReferenceURL(relativePathRef))

	identifiedURL, _ := urlidentification.IdentifyURLString("http://google.com")
	fmt.Println(identifiedURL == urlidentification.Absolute)
}

Running the previous program should outpout:

is absolute url: true
is network path reference: true
is relative reference with absolute path: true
is relative path reference: true
true

License

The BSD 3-Clause license.

About

URL identification based on nomenclature specified in RFC 3986

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages