MCPcopy Index your code
hub / github.com/coder/coder / TestNormalizePathSegments

Function TestNormalizePathSegments

coderd/httpmw/httpmw_internal_test.go:168–210  ·  view source on GitHub ↗

TestNormalizePathSegments tests path normalization including dot-segment removal

(t *testing.T)

Source from the content-addressed store, hash-verified

166
167// TestNormalizePathSegments tests path normalization including dot-segment removal
168func TestNormalizePathSegments(t *testing.T) {
169 t.Parallel()
170
171 testCases := []struct {
172 name string
173 input string
174 expected string
175 }{
176 {
177 name: "EmptyString",
178 input: "",
179 expected: "/",
180 },
181 {
182 name: "SimplePath",
183 input: "/api/v1",
184 expected: "/api/v1",
185 },
186 {
187 name: "PathWithDotSegments",
188 input: "/api/../v1/./test",
189 expected: "/v1/test",
190 },
191 {
192 name: "TrailingSlash",
193 input: "/api/v1/",
194 expected: "/api/v1",
195 },
196 {
197 name: "MultipleSlashes",
198 input: "/api//v1///test",
199 expected: "/api//v1///test",
200 },
201 }
202
203 for _, tc := range testCases {
204 t.Run(tc.name, func(t *testing.T) {
205 t.Parallel()
206 result := normalizePathSegments(tc.input)
207 assert.Equal(t, tc.expected, result)
208 })
209 }
210}
211
212// TestExtractExpectedAudience tests audience extraction from HTTP requests
213func TestExtractExpectedAudience(t *testing.T) {

Callers

nothing calls this directly

Calls 3

normalizePathSegmentsFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected