MCPcopy
hub / github.com/caddyserver/caddy / TestSplitPos

Function TestSplitPos

modules/caddyhttp/reverseproxy/fastcgi/fastcgi_test.go:73–280  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func TestSplitPos(t *testing.T) {
74 tests := []struct {
75 name string
76 path string
77 splitPath []string
78 wantPos int
79 }{
80 {
81 name: "simple php extension",
82 path: "/path/to/script.php",
83 splitPath: []string{".php"},
84 wantPos: 19,
85 },
86 {
87 name: "php extension with path info",
88 path: "/path/to/script.php/some/path",
89 splitPath: []string{".php"},
90 wantPos: 19,
91 },
92 {
93 name: "case insensitive match",
94 path: "/path/to/script.PHP",
95 splitPath: []string{".php"},
96 wantPos: 19,
97 },
98 {
99 name: "mixed case match",
100 path: "/path/to/script.PhP/info",
101 splitPath: []string{".php"},
102 wantPos: 19,
103 },
104 {
105 name: "no match",
106 path: "/path/to/script.txt",
107 splitPath: []string{".php"},
108 wantPos: -1,
109 },
110 {
111 name: "empty split path",
112 path: "/path/to/script.php",
113 splitPath: []string{},
114 wantPos: 0,
115 },
116 {
117 name: "multiple split paths first match",
118 path: "/path/to/script.php",
119 splitPath: []string{".php", ".phtml"},
120 wantPos: 19,
121 },
122 {
123 name: "multiple split paths second match",
124 path: "/path/to/script.phtml",
125 splitPath: []string{".php", ".phtml"},
126 wantPos: 21,
127 },
128 // Unicode case-folding tests (security fix for GHSA-g966-83w7-6w38)
129 // U+023A (Ⱥ) lowercases to U+2C65 (ⱥ), which has different UTF-8 byte length
130 // Ⱥ: 2 bytes (C8 BA), ⱥ: 3 bytes (E2 B1 A5)

Callers

nothing calls this directly

Calls 2

splitPosMethod · 0.80
EqualMethod · 0.45

Tested by

no test coverage detected