Bluesky app fork with some witchin' additions 💫

embedr: handle out-of-range maxwidth; change default (#3713)

authored by bnewbold.net and committed by

GitHub d81a373d f2797218

+10 -4
+10 -4
bskyweb/cmd/embedr/handlers.go
··· 122 122 } 123 123 124 124 // TODO: do we actually do something with width? 125 - width := 550 125 + width := 600 126 126 maxWidthParam := c.QueryParam("maxwidth") 127 127 if maxWidthParam != "" { 128 128 maxWidthInt, err := strconv.Atoi(maxWidthParam) 129 - if err != nil || maxWidthInt < 220 || maxWidthInt > 550 { 130 - return c.String(http.StatusBadRequest, "Invalid maxwidth (expected integer between 220 and 550)") 129 + if err != nil { 130 + return c.String(http.StatusBadRequest, "Invalid maxwidth (expected integer)") 131 131 } 132 - width = maxWidthInt 132 + if maxWidthInt < 220 { 133 + width = 220 134 + } else if maxWidthInt > 600 { 135 + width = 600 136 + } else { 137 + width = maxWidthInt 138 + } 133 139 } 134 140 // NOTE: maxheight ignored 135 141