@@ -114,7 +114,8 @@ func (handler *V1Handler) postLobby(writer http.ResponseWriter, request *http.Re
114114 }
115115
116116 scoreCalculation , scoreCalculationInvalid := ParseScoreCalculation (request .Form .Get ("score_calculation" ))
117- languageData , languageKey , languageInvalid := ParseLanguage (request .Form .Get ("language" ))
117+ languageRawValue := strings .ToLower (strings .TrimSpace (request .Form .Get ("language" )))
118+ languageData , languageKey , languageInvalid := ParseLanguage (languageRawValue )
118119 drawingTime , drawingTimeInvalid := ParseDrawingTime (handler .cfg , request .Form .Get ("drawing_time" ))
119120 rounds , roundsInvalid := ParseRounds (handler .cfg , request .Form .Get ("rounds" ))
120121 maxPlayers , maxPlayersInvalid := ParseMaxPlayers (handler .cfg , request .Form .Get ("max_players" ))
@@ -133,6 +134,7 @@ func (handler *V1Handler) postLobby(writer http.ResponseWriter, request *http.Re
133134 } else {
134135 lowercaser = languageData .Lowercaser ()
135136 }
137+
136138 customWords , customWordsInvalid := ParseCustomWords (lowercaser , request .Form .Get ("custom_words" ))
137139
138140 if scoreCalculationInvalid != nil {
@@ -155,6 +157,10 @@ func (handler *V1Handler) postLobby(writer http.ResponseWriter, request *http.Re
155157 }
156158 if customWordsPerTurnInvalid != nil {
157159 requestErrors = append (requestErrors , customWordsPerTurnInvalid .Error ())
160+ } else {
161+ if languageRawValue == "custom" && len (customWords ) == 0 {
162+ requestErrors = append (requestErrors , "custom words must be provided when using custom language" )
163+ }
158164 }
159165 if clientsPerIPLimitInvalid != nil {
160166 requestErrors = append (requestErrors , clientsPerIPLimitInvalid .Error ())
0 commit comments