Skip to content

Commit

Permalink
Fix X-ShopId header check when header value is empty
Browse files Browse the repository at this point in the history
Closes SHARP-995
  • Loading branch information
nozzlegear committed Jan 17, 2024
1 parent 54643df commit 783bb30
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ShopifySharp/Utilities/ShopifyDomainUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ public async Task<bool> IsValidShopDomainAsync(string shopDomain, CancellationTo

try
{
const string headerName = "X-ShopId";
var response = await client.SendAsync(msg, HttpCompletionOption.ResponseHeadersRead, cancellationToken);
var hasShopIdHeader = response.Headers.Any(h => h.Key.Equals("X-ShopId", StringComparison.OrdinalIgnoreCase));
var headerValues = response.Headers.FirstOrDefault(h => h.Key.Equals(headerName, StringComparison.OrdinalIgnoreCase)).Value;

return hasShopIdHeader;
return headerValues != null && headerValues.Any(v => !string.IsNullOrWhiteSpace(v));
}
catch (HttpRequestException)
{
Expand Down

0 comments on commit 783bb30

Please sign in to comment.