@@ -198,6 +198,40 @@ func TestHandleHistory_CompareURLIncludesAllPackages(t *testing.T) {
198198 }
199199}
200200
201+ func TestHandleFunDetail_CamelCaseRedirect (t * testing.T ) {
202+ manifest , _ := layout .NewManifest ([]byte (`{}` ))
203+ handler := NewHandler (nil , manifest )
204+
205+ tests := []struct {
206+ input string
207+ location string
208+ }{
209+ {"DesktopEnvironments" , "/fun/Desktop%20Environments/current" },
210+ {"WindowManagers" , "/fun/Window%20Managers/history" },
211+ {"TerminalEmulators" , "/fun/Terminal%20Emulators/current" },
212+ }
213+
214+ for _ , tt := range tests {
215+ preset := "current"
216+ if strings .Contains (tt .location , "history" ) {
217+ preset = "history"
218+ }
219+ req := httptest .NewRequest (http .MethodGet , "/fun/" + tt .input + "/" + preset , nil )
220+ req .SetPathValue ("category" , tt .input )
221+ req .SetPathValue ("preset" , preset )
222+ rr := httptest .NewRecorder ()
223+
224+ handler .HandleFunDetail (rr , req )
225+
226+ if rr .Code != http .StatusMovedPermanently {
227+ t .Errorf ("%s: expected 301, got %d" , tt .input , rr .Code )
228+ }
229+ if got := rr .Header ().Get ("Location" ); got != tt .location {
230+ t .Errorf ("%s: expected Location %q, got %q" , tt .input , tt .location , got )
231+ }
232+ }
233+ }
234+
201235func TestHandleFunDetail_InvalidCategory (t * testing.T ) {
202236 manifest , _ := layout .NewManifest ([]byte (`{}` ))
203237 handler := NewHandler (nil , manifest )
0 commit comments