Skip to content

Commit

Permalink
Fix relative path url generation (#129)
Browse files Browse the repository at this point in the history
All bundle paths seem to end up starting with a "/" which is absolute as far as Path.Combine is concerned. When combining with wwwroot the full path gets lost and the incorrect url gets generated. Removing the '/' at the start of the asset fixes this issue
  • Loading branch information
Meberem authored Jul 23, 2020
1 parent 8e939bb commit f9c0b86
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/WebOptimizer.Core/Processors/RelativePathAdjuster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override Task ExecuteAsync(IAssetContext config)
foreach (string key in config.Content.Keys)
{
IFileInfo input = fileProvider.GetFileInfo(key);
string outputPath = Path.Combine(env.WebRootPath, config.Asset.Route);
string outputPath = Path.Combine(env.WebRootPath, config.Asset.Route.TrimStart('/'));

content[key] = Adjust(config.Content[key].AsString(), input.PhysicalPath, outputPath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async Task AdjustRelativePaths_Success(string url, string newUrl)
.Returns(@"//source");

context.SetupGet(s => s.Asset.Route)
.Returns(@"dist/all.css");
.Returns(@"/dist/all.css");

context.Setup(s => s.HttpContext.RequestServices.GetService(typeof(IAssetPipeline)))
.Returns(pipeline.Object);
Expand Down

0 comments on commit f9c0b86

Please sign in to comment.