@@ -449,7 +449,7 @@ export class MetadataManager implements IMetadataService {
449449 // ==========================================
450450
451451 private overlayKey ( type : string , name : string , scope : string = 'platform' ) : string {
452- return `${ type } :${ name } :${ scope } ` ;
452+ return `${ encodeURIComponent ( type ) } :${ encodeURIComponent ( name ) } :${ scope } ` ;
453453 }
454454
455455 /**
@@ -704,7 +704,7 @@ export class MetadataManager implements IMetadataService {
704704 * Get metadata items that this item depends on
705705 */
706706 async getDependencies ( type : string , name : string ) : Promise < MetadataDependency [ ] > {
707- return this . dependencies . get ( `${ type } :${ name } ` ) ?? [ ] ;
707+ return this . dependencies . get ( `${ encodeURIComponent ( type ) } :${ encodeURIComponent ( name ) } ` ) ?? [ ] ;
708708 }
709709
710710 /**
@@ -725,13 +725,20 @@ export class MetadataManager implements IMetadataService {
725725 /**
726726 * Register a dependency between two metadata items.
727727 * Used internally to track cross-references.
728+ * Duplicate dependencies (same source, target, and kind) are ignored.
728729 */
729730 addDependency ( dep : MetadataDependency ) : void {
730- const key = `${ dep . sourceType } :${ dep . sourceName } ` ;
731+ const key = `${ encodeURIComponent ( dep . sourceType ) } :${ encodeURIComponent ( dep . sourceName ) } ` ;
731732 if ( ! this . dependencies . has ( key ) ) {
732733 this . dependencies . set ( key , [ ] ) ;
733734 }
734- this . dependencies . get ( key ) ! . push ( dep ) ;
735+ const existing = this . dependencies . get ( key ) ! ;
736+ const isDuplicate = existing . some (
737+ d => d . targetType === dep . targetType && d . targetName === dep . targetName && d . kind === dep . kind
738+ ) ;
739+ if ( ! isDuplicate ) {
740+ existing . push ( dep ) ;
741+ }
735742 }
736743
737744 // ==========================================
0 commit comments