Skip to content
Switch branches/tags

Latest commit

Add gemini:// and moz-extension:// schemes.

moz-extension:// is used by Firefox addons. People using FF devtools
frequently end up copying moz-extension URLs, so it might make sense to
include their scheme.

gemini:// is a new protocol for a network that sits somewhere between
Gopher and the WWW. Although not registered with the IANA yet, it does
have an acative community that shares a lot of gemini:// links in various
places. xurls should recognize these. More info at and gemini://

Git stats


Failed to load latest commit information.


Go Reference

Extract urls from text using regular expressions. Requires Go 1.16 or later.

import ""

func main() {
	rxRelaxed := xurls.Relaxed()
	rxRelaxed.FindString("Do gophers live in")  // ""
	rxRelaxed.FindString("This string does not have a URL") // ""

	rxStrict := xurls.Strict()
	rxStrict.FindAllString("must have scheme:", -1) // []string{""}
	rxStrict.FindAllString("no scheme, no match:", -1)       // []string{}

Since API is centered around regexp.Regexp, many other methods are available, such as finding the byte indexes for all matches.

Note that calling the exposed functions means compiling a regular expression, so repeated calls should be avoided.


To install the tool globally:

go install
$ echo "Do gophers live in" | xurls