File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
packages/router/src/unplugin/core Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -1275,6 +1275,14 @@ describe('Tree', () => {
12751275 expect ( c . children . has ( '_parent' ) ) . toBe ( false )
12761276 } )
12771277
1278+ it ( 'does not flag named views as conflicts' , ( ) => {
1279+ const tree = new PrefixTree ( RESOLVED_OPTIONS )
1280+ tree . insert ( 'posts/index' , 'posts/index.vue' )
1281+ tree . insert ( 'posts/index@header' , 'posts/index@header.vue' )
1282+
1283+ expect ( collectDuplicatedRouteNodes ( tree ) ) . toEqual ( [ ] )
1284+ } )
1285+
12781286 it ( 'collects _parent conflicts' , ( ) => {
12791287 const tree = new PrefixTree ( RESOLVED_OPTIONS )
12801288 const nested = tree . insert ( 'nested' , 'nested.vue' )
Original file line number Diff line number Diff line change @@ -624,7 +624,12 @@ export function collectDuplicatedRouteNodes(
624624 }
625625
626626 const dups = Array . from ( seen . values ( ) )
627- . filter ( nodes => Object . keys ( nodes ) . length > 1 )
627+ // All entries in a group reference the same TreeNode instance, so
628+ // comparing the number of files to components.size tells us if any
629+ // file was overwritten (e.g. index.vue vs index@default.vue both
630+ // targeting the "default" view). Different named views on the same
631+ // node (e.g. index.vue + index@header.vue) are not conflicts.
632+ . filter ( nodes => nodes . length > nodes [ 0 ] . node . value . components . size )
628633 . map ( nodes =>
629634 nodes . toSorted ( ( { node : a } , { node : b } ) => {
630635 // put the one that takes precedence at the end of the list
You can’t perform that action at this time.
0 commit comments