summaryrefslogtreecommitdiff
path: root/vendor/github.com/client9/misspell/url.go
blob: 1a259f5f99ccf6757083667d59507a75e20a2882 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package misspell

import (
	"regexp"
)

// Regexp for URL https://mathiasbynens.be/demo/url-regex
//
// original @imme_emosol (54 chars) has trouble with dashes in hostname
// @(https?|ftp)://(-\.)?([^\s/?\.#-]+\.?)+(/[^\s]*)?$@iS
var reURL = regexp.MustCompile(`(?i)(https?|ftp)://(-\.)?([^\s/?\.#]+\.?)+(/[^\s]*)?`)

// StripURL attemps to replace URLs with blank spaces, e.g.
//  "xxx http://foo.com/ yyy -> "xxx          yyyy"
func StripURL(s string) string {
	return reURL.ReplaceAllStringFunc(s, replaceWithBlanks)
}