File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
src/Masa.Stack.Components/Shared/Layouts/Components Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ private void UpdateItems()
43
43
{
44
44
Items = new ( ) ;
45
45
46
- var absolutePath = new Uri ( NavigationManager . Uri ) . AbsolutePath ;
46
+ var absolutePath = GetNormalizedAbsolutePath ( NavigationManager . Uri , NavigationManager . ProjectPrefix ) ;
47
47
var matchedNavs = FlattenedNavs . Where ( n =>
48
48
{
49
49
try
@@ -205,5 +205,20 @@ protected override ValueTask DisposeAsyncCore()
205
205
NavigationManager . LocationChanged -= NavigationManagerOnLocationChanged ;
206
206
return base . DisposeAsyncCore ( ) ;
207
207
}
208
+
209
+ private string GetNormalizedAbsolutePath ( string uri , string ? projectPrefix )
210
+ {
211
+ var absolutePath = new Uri ( uri ) . AbsolutePath ;
212
+ projectPrefix = projectPrefix ? . TrimEnd ( '/' ) ?? string . Empty ;
213
+ if ( ! string . IsNullOrEmpty ( projectPrefix ) && absolutePath . StartsWith ( projectPrefix , StringComparison . OrdinalIgnoreCase ) )
214
+ {
215
+ absolutePath = absolutePath [ projectPrefix . Length ..] ;
216
+ if ( ! absolutePath . StartsWith ( "/" ) )
217
+ {
218
+ absolutePath = "/" + absolutePath ;
219
+ }
220
+ }
221
+ return absolutePath ;
222
+ }
208
223
}
209
224
}
You can’t perform that action at this time.
0 commit comments