MCPcopy Create free account
hub / github.com/github/gh-aw / TestExtractDomainFromURL

Function TestExtractDomainFromURL

pkg/stringutil/urls_test.go:11–118  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestExtractDomainFromURL(t *testing.T) {
12 tests := []struct {
13 name string
14 url string
15 expected string
16 }{
17 // Test cases from pkg/cli/access_log_test.go
18 {
19 name: "HTTP URL with path",
20 url: "http://example.com/path",
21 expected: "example.com",
22 },
23 {
24 name: "HTTPS URL with path",
25 url: "https://api.github.com/repos",
26 expected: "api.github.com",
27 },
28 {
29 name: "domain with port",
30 url: "github.com:443",
31 expected: "github.com",
32 },
33 {
34 name: "plain domain",
35 url: "malicious.site",
36 expected: "malicious.site",
37 },
38 {
39 name: "HTTP URL with port and path",
40 url: "http://sub.domain.com:8080/path",
41 expected: "sub.domain.com",
42 },
43 // Test cases from pkg/workflow/http_mcp_domains_test.go
44 {
45 name: "HTTPS URL with MCP path",
46 url: "https://mcp.tavily.com/mcp/",
47 expected: "mcp.tavily.com",
48 },
49 {
50 name: "HTTP URL with port and API path",
51 url: "http://api.example.com:8080/path",
52 expected: "api.example.com",
53 },
54 {
55 name: "domain only",
56 url: "mcp.example.com",
57 expected: "mcp.example.com",
58 },
59 {
60 name: "HTTPS URL with port",
61 url: "https://api.example.com:3000",
62 expected: "api.example.com",
63 },
64 {
65 name: "URL with subdomain",
66 url: "https://api.mcp.example.com/v1/endpoint",
67 expected: "api.mcp.example.com",
68 },

Callers

nothing calls this directly

Calls 2

ExtractDomainFromURLFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected