Skip to content

Commit

Permalink
♻️ use own implementation for trimming all strings in a collection
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffynuts committed Apr 4, 2024
1 parent b6b9b76 commit 96740ec
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Http;
using PeanutButter.Utils;

#if BUILD_PEANUTBUTTER_INTERNAL
namespace Imported.PeanutButter.TestUtils.AspNetCore;
Expand Down Expand Up @@ -43,10 +43,10 @@ string cookieName
throw new CookieNotFoundException(cookieName);
}

var parts = cookieHeader.Split(";").Trim();
var parts = TrimAll(cookieHeader.Split(";"));
foreach (var part in parts)
{
var subs = part.Split('=').Trim().ToArray();
var subs = TrimAll(part.Split('='));
if (subs[0].Equals("SameSite", StringComparison.OrdinalIgnoreCase))
{
return Enum.TryParse<SameSiteMode>(subs[1], out var parsed)
Expand All @@ -57,4 +57,9 @@ string cookieName

return SameSiteMode.None;
}

private static string[] TrimAll(IEnumerable<string> source)
{
return source.Select(s => s.Trim()).ToArray();
}
}

0 comments on commit 96740ec

Please sign in to comment.