Validate screenshot URLs server- and client-side
This commit is contained in:
@@ -51,6 +51,11 @@ public static class SuggestEndpoints
|
||||
return Results.BadRequest(new { error = "Name is required and must be <= 100 characters." });
|
||||
}
|
||||
|
||||
if (!EndpointHelpers.IsValidImageUrl(request.ScreenshotUrl))
|
||||
{
|
||||
return Results.BadRequest(new { error = "Screenshot URL must be http(s) and end with an image file extension." });
|
||||
}
|
||||
|
||||
var player = await EndpointHelpers.GetAuthenticatedPlayer(ctx, db);
|
||||
if (player is null) return Results.Unauthorized();
|
||||
|
||||
@@ -118,6 +123,11 @@ public static class SuggestEndpoints
|
||||
return Results.BadRequest(new { error = "Name is required and must be <= 100 characters." });
|
||||
}
|
||||
|
||||
if (!EndpointHelpers.IsValidImageUrl(request.ScreenshotUrl))
|
||||
{
|
||||
return Results.BadRequest(new { error = "Screenshot URL must be http(s) and end with an image file extension." });
|
||||
}
|
||||
|
||||
var suggestion = await db.Suggestions.FirstOrDefaultAsync(s => s.Id == id);
|
||||
if (suggestion == null) return Results.NotFound(new { error = "Suggestion not found." });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user