Skip to content

xmidt-org/urlegit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

urlegit

URLegit is a library for validating URLs.

Build Status codecov.io Go Report Card Apache V2 License GitHub Release GoDoc

Summary

URL validation is complex and very specific to the task at hand. This library's goal is to provide a toolkit for making pre-flight checks against a URL easier.

Usage

package main

import (
	"fmt"

	"github.com/xmidt-org/urlegit"
)

func main() {
	c, err := urlegit.New(
		urlegit.OnlyScheme("https"),
		urlegit.ForbidSpecialUseDomains(),
	)

	if err != nil {
		panic(err)
	}

	url := "https://github.com"
	fmt.Printf("Is %q allowed? %t\n", url, c.Legit(url))

	// Output:
	// Is "https://github.com" allowed? true
}

Go Playground

Resources

Footnotes

This library originally started of in xmidt-org/ancla as webhook URL validation code. Here is a perma link to that code.