Passed
Pull Request — main (#38)
by Igor
02:08
created

is.RelativeURL   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
package is
2
3
import "github.com/muonsoft/validation/validate"
4
5
// URL is used to check that value is a valid absolute URL string, which means that a protocol (or scheme) is required.
6
// By default (if no protocols are passed), the function checks only for the http:// and https:// protocols.
7
// Use the protocols argument to configure the list of expected protocols.
8
func URL(value string, protocols ...string) bool {
9
	return validate.URL(value, protocols...) == nil
10
}
11
12
// RelativeURL is used to check that value is a valid absolute or relative URL string. The protocol is considered
13
// optional when validating the syntax of the given URL. This means that both http:// and https:// are valid
14
// but also relative URLs that contain no protocol (e.g. //example.com). By default, the function checks
15
// only for the http:// and https:// protocols. Use the protocols argument to configure
16
// the list of expected protocols.
17
func RelativeURL(value string, protocols ...string) bool {
18
	return validate.RelativeURL(value, protocols...) == nil
19
}
20