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()
4343 {
4444 Items = new ( ) ;
4545
46- var absolutePath = new Uri ( NavigationManager . Uri ) . AbsolutePath ;
46+ var absolutePath = GetNormalizedAbsolutePath ( NavigationManager . Uri , NavigationManager . ProjectPrefix ) ;
4747 var matchedNavs = FlattenedNavs . Where ( n =>
4848 {
4949 try
@@ -205,5 +205,20 @@ protected override ValueTask DisposeAsyncCore()
205205 NavigationManager . LocationChanged -= NavigationManagerOnLocationChanged ;
206206 return base . DisposeAsyncCore ( ) ;
207207 }
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+ }
208223 }
209224}
You can’t perform that action at this time.
0 commit comments