Skip to content

Commit 2821506

Browse files
.NET 7 fixes
Update ImageSharp.Web.csproj
1 parent 438daf0 commit 2821506

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/ImageSharp.Web/Commands/PresetOnlyQueryCollectionRequestParser.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public CommandCollection ParseRequestCommands(HttpContext context)
4040
}
4141

4242
StringValues query = queryCollection[QueryKey];
43-
string requestedPreset = query[query.Count - 1];
44-
if (this.presets.TryGetValue(requestedPreset, out CommandCollection? collection))
43+
string? requestedPreset = query[^1];
44+
if (requestedPreset is not null && this.presets.TryGetValue(requestedPreset, out CommandCollection? collection))
4545
{
4646
return collection;
4747
}
@@ -65,7 +65,11 @@ private static CommandCollection ParsePreset(string unparsedPresetValue)
6565
foreach (KeyValuePair<string, StringValues> pair in parsed)
6666
{
6767
// Use the indexer for both set and query. This replaces any previously parsed values.
68-
transformed[pair.Key] = pair.Value[pair.Value.Count - 1];
68+
string? value = pair.Value[^1];
69+
if (value is not null)
70+
{
71+
transformed[pair.Key] = value;
72+
}
6973
}
7074

7175
return transformed;

src/ImageSharp.Web/Commands/QueryCollectionRequestParser.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ public CommandCollection ParseRequestCommands(HttpContext context)
2525
foreach (KeyValuePair<string, StringValues> pair in query)
2626
{
2727
// Use the indexer for both set and query. This replaces any previously parsed values.
28-
transformed[pair.Key] = pair.Value[pair.Value.Count - 1];
28+
string? value = pair.Value[^1];
29+
if (value is not null)
30+
{
31+
transformed[pair.Key] = value;
32+
}
2933
}
3034

3135
return transformed;

0 commit comments

Comments
 (0)