[build] Fix pre-fingerprinted static assets collected from razor class libraries not being mapped correctly
This commit is contained in:
parent
0bf88aec43
commit
5995f232e9
1 changed files with 5 additions and 2 deletions
|
@ -50,7 +50,8 @@ public class RewriteStaticAssetManifest : Microsoft.Build.Utilities.Task
|
||||||
// Get a list of constrained routes
|
// Get a list of constrained routes
|
||||||
var brotliRoutes = manifest.Endpoints
|
var brotliRoutes = manifest.Endpoints
|
||||||
.Where(p => p.Selectors is [{ Name: "Content-Encoding", Value: "br" }])
|
.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
|
p => p.ResponseHeaders
|
||||||
.FirstOrDefault(i => i.Name == "Content-Length"));
|
.FirstOrDefault(i => i.Name == "Content-Length"));
|
||||||
|
|
||||||
|
@ -60,7 +61,9 @@ public class RewriteStaticAssetManifest : Microsoft.Build.Utilities.Task
|
||||||
foreach (var endpoint in arr)
|
foreach (var endpoint in arr)
|
||||||
{
|
{
|
||||||
if (endpoint.Selectors.Count > 0) continue;
|
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}");
|
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);
|
var origLen = endpoint.ResponseHeaders.First(p => p.Name == len.Name);
|
||||||
endpoint.Properties.Add(new StaticAssetProperty("Uncompressed-Length", origLen.Value));
|
endpoint.Properties.Add(new StaticAssetProperty("Uncompressed-Length", origLen.Value));
|
||||||
|
|
Loading…
Add table
Reference in a new issue