Skip to content

Commit dbf3d60

Browse files
authored
Merge pull request #25340 from abpframework/maliming/fix-blazor-bundle-webassembly-files
fix: blazor `<AbpStyles>`/`<AbpScripts>` lose `PathBase` for WebAssembly files
2 parents 0ed505d + a39ec69 commit dbf3d60

4 files changed

Lines changed: 22 additions & 3 deletions

File tree

framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Bundling/AbpScripts.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
{
4646
if (OperatingSystem.IsBrowser() && WebAssemblyScriptFiles != null)
4747
{
48-
ScriptFiles = WebAssemblyScriptFiles;
48+
ScriptFiles = await ResolveAsync(WebAssemblyScriptFiles);
4949
}
5050
}
5151
}

framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Bundling/AbpStyles.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
StyleFiles = scriptFiles;
4747
if (OperatingSystem.IsBrowser() && StyleFiles != null && WebAssemblyStyleFiles != null)
4848
{
49-
StyleFiles.AddIfNotContains(WebAssemblyStyleFiles);
49+
StyleFiles.AddIfNotContains(await ResolveAsync(WebAssemblyStyleFiles));
5050
}
5151
}
5252
}
@@ -59,7 +59,7 @@
5959
{
6060
_hasRemoveServerStyle = true;
6161
await Task.Delay(3000);
62-
StyleFiles = WebAssemblyStyleFiles;
62+
StyleFiles = await ResolveAsync(WebAssemblyStyleFiles);
6363
StateHasChanged();
6464
}
6565
}

framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Bundling/ComponentBundleUrlBuilder.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public virtual Task<string> BuildAsync(
3434
return Task.FromResult(fileName);
3535
}
3636

37+
if (fileName.StartsWith(normalized, StringComparison.Ordinal))
38+
{
39+
return Task.FromResult(fileName);
40+
}
41+
3742
return Task.FromResult(normalized + fileName.RemovePreFix("/"));
3843
}
3944

framework/test/Volo.Abp.AspNetCore.Components.Web.Theming.Tests/Volo/Abp/AspNetCore/Components/Web/Theming/Bundling/ComponentBundleUrlBuilder_Tests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,18 @@ public async Task Should_Treat_Whitespace_AppBasePath_As_Not_Provided()
102102
(await _builder.BuildAsync("/__bundles/Global.css", appBasePath: " ", navigationBaseUri: "https://localhost/foo/"))
103103
.ShouldBe("/foo/__bundles/Global.css");
104104
}
105+
106+
[Fact]
107+
public async Task Should_Be_Idempotent_For_Already_Prefixed_FileName()
108+
{
109+
(await _builder.BuildAsync("/foo/__bundles/Global.css", appBasePath: "/foo", navigationBaseUri: null))
110+
.ShouldBe("/foo/__bundles/Global.css");
111+
}
112+
113+
[Fact]
114+
public async Task Should_Be_Idempotent_When_PathBase_Resolved_From_NavigationBaseUri()
115+
{
116+
(await _builder.BuildAsync("/foo/__bundles/Global.css", appBasePath: null, navigationBaseUri: "https://localhost/foo/"))
117+
.ShouldBe("/foo/__bundles/Global.css");
118+
}
105119
}

0 commit comments

Comments
 (0)