Skip to content

Commit

Permalink
fix: Enquote hashed string to comply with schema
Browse files Browse the repository at this point in the history
  • Loading branch information
MH321Productions committed Feb 27, 2025
1 parent 59af260 commit 58e2606
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NeoSmart.Utils;

namespace Backbone.Modules.Tags.ConsumerApi.Controllers;

Expand All @@ -27,11 +28,12 @@ public async Task<IActionResult> ListTags([FromHeader(Name = "If-None-Match")] s
var response = await _mediator.Send(new ListTagsQuery(), cancellationToken);
var json = JsonSerializer.SerializeToUtf8Bytes(response);
var responseHash = _hasher.ComputeHash(json);
var hashString = Convert.ToBase64String(responseHash);
var hashString = UrlBase64.Encode(responseHash);
var etag = $"\"{hashString}\"";

Response.Headers.ETag = hashString;
Response.Headers.ETag = etag;

if (ifNoneMatch != null && ifNoneMatch.SequenceEqual(hashString))
if (ifNoneMatch != null && (ifNoneMatch.SequenceEqual(etag) || ifNoneMatch.SequenceEqual(hashString)))
return StatusCode(StatusCodes.Status304NotModified);

return Ok(response);
Expand Down

0 comments on commit 58e2606

Please sign in to comment.