@@ -317,7 +317,15 @@ function completePathDynamic(app: AppInterface, newChild: Node): void {
317317 // If it is the anchor tag,eg. <a href="#xxx"/>, the path will not be completed
318318 ( / ^ ( a ) $ / i. test ( newChild . tagName ) && newChild . hasAttribute ( 'href' ) && ! / ^ # / . test ( newChild . getAttribute ( 'href' ) || '' ) )
319319 ) {
320- globalEnv . rawSetAttribute . call ( newChild , 'href' , CompletionPath ( newChild . getAttribute ( 'href' ) ! , app . url ) )
320+ const aHrefResolver = microApp ?. options ?. aHrefResolver
321+ const hrefValue = newChild . getAttribute ( 'href' ) !
322+ let nextHrefValue
323+ if ( ( / ^ ( a ) $ / i. test ( newChild . tagName ) && typeof aHrefResolver === 'function' ) ) {
324+ nextHrefValue = aHrefResolver ( hrefValue , app . name , app . url )
325+ } else {
326+ nextHrefValue = CompletionPath ( hrefValue , app . url )
327+ }
328+ globalEnv . rawSetAttribute . call ( newChild , 'href' , nextHrefValue )
321329 }
322330 }
323331}
@@ -560,7 +568,12 @@ export function patchElementAndDocument(): void {
560568
561569 ) {
562570 const app = appInstanceMap . get ( appName )
563- value = CompletionPath ( value , app ! . url )
571+ const aHrefResolver = microApp ?. options ?. aHrefResolver
572+ if ( key === 'href' && / ^ a $ / i. test ( this . tagName ) && typeof aHrefResolver === 'function' ) {
573+ value = aHrefResolver ( value , appName , app ! . url )
574+ } else {
575+ value = CompletionPath ( value , app ! . url )
576+ }
564577 }
565578 globalEnv . rawSetAttribute . call ( this , key , value )
566579 if ( isImageElement ( this ) || isVideoElement ( this ) || isAudioElement ( this ) ) {
0 commit comments