MCPcopy Create free account
hub / github.com/cloudwan/gohan / TestIsURLRelative

Function TestIsURLRelative

schema/url_test.go:23–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21)
22
23func TestIsURLRelative(t *testing.T) {
24 t.Parallel()
25
26 data := []struct {
27 Rawurl string
28 Relative bool
29 }{
30 {"foobar", true},
31 {"./foobar", true},
32 {"/foobar", false},
33
34 {"file://foobar", true},
35 {"file://./foobar", true},
36 {"file://../foobar", true},
37 {"file://../../foobar", true},
38 {"file:///foobar", false},
39
40 {"http://foo.bar", false},
41 }
42
43 for _, d := range data {
44 u, err := url.Parse(d.Rawurl)
45 if err != nil {
46 panic("Wrong URL")
47 }
48 if isURLRelative(u) != d.Relative {
49 t.Error("Mismatch on", d)
50 }
51 }
52}
53
54func TestFixRelativeURL(t *testing.T) {
55 t.Parallel()

Callers

nothing calls this directly

Calls 3

isURLRelativeFunction · 0.85
ParseMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected