From 5995f232e9bedb1530696650df81fd7ff09f3a57 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Wed, 19 Feb 2025 00:36:54 +0100 Subject: [PATCH] [build] Fix pre-fingerprinted static assets collected from razor class libraries not being mapped correctly --- Iceshrimp.Build/RewriteStaticAssetManifestTask.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Iceshrimp.Build/RewriteStaticAssetManifestTask.cs b/Iceshrimp.Build/RewriteStaticAssetManifestTask.cs index a9a9959d..4f19b8b9 100644 --- a/Iceshrimp.Build/RewriteStaticAssetManifestTask.cs +++ b/Iceshrimp.Build/RewriteStaticAssetManifestTask.cs @@ -50,7 +50,8 @@ public class RewriteStaticAssetManifest : Microsoft.Build.Utilities.Task // Get a list of constrained routes var brotliRoutes = manifest.Endpoints .Where(p => p.Selectors is [{ Name: "Content-Encoding", Value: "br" }]) - .ToDictionary(p => p.Route, + .DistinctBy(p => p.AssetPath) + .ToDictionary(p => p.AssetPath, p => p.ResponseHeaders .FirstOrDefault(i => i.Name == "Content-Length")); @@ -60,7 +61,9 @@ public class RewriteStaticAssetManifest : Microsoft.Build.Utilities.Task foreach (var endpoint in arr) { if (endpoint.Selectors.Count > 0) continue; - if (!brotliRoutes.TryGetValue(endpoint.AssetPath, out var len)) continue; + if (!brotliRoutes.TryGetValue(endpoint.AssetPath + ".br", out var len)) + continue; + if (len is null) throw new Exception($"Couldn't find content-length for route ${endpoint.Route}"); var origLen = endpoint.ResponseHeaders.First(p => p.Name == len.Name); endpoint.Properties.Add(new StaticAssetProperty("Uncompressed-Length", origLen.Value));