Skip to content

Commit

Permalink
trim whitespace from teacher and course query parameters in Suggestio…
Browse files Browse the repository at this point in the history
…nsSearchQuery
  • Loading branch information
GiridharRNair committed Jan 13, 2025
1 parent b33cc7f commit 6fde5aa
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/controllers/search_suggestions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controllers

import (
"net/http"
"strings"

"github.com/GiridharRNair/ProfStats-GinAPI/db"
"github.com/gin-gonic/gin"
Expand All @@ -15,6 +16,9 @@ func SuggestionsSearchQuery(c *gin.Context) {
teacher := c.Query("teacher")
course := c.Query("course")

teacher = strings.TrimSpace(teacher)
course = strings.TrimSpace(course)

if teacher == "" && course == "" {
c.JSON(http.StatusOK, gin.H{"professors": defaultProfessorSuggestions, "courses": defaultCourseSuggestions})
return
Expand Down

0 comments on commit 6fde5aa

Please sign in to comment.