@@ -1090,6 +1090,56 @@ describe("handleControlUiHttpRequest", () => {
10901090 } ) ;
10911091 } ) ;
10921092
1093+ it . each ( [
1094+ {
1095+ name : "root-mounted nested routes" ,
1096+ requestPath : "/settings/approvals" ,
1097+ basePath : undefined ,
1098+ expectedPrefix : "" ,
1099+ } ,
1100+ {
1101+ name : "base-mounted nested routes" ,
1102+ requestPath : "/openclaw/settings/approvals" ,
1103+ basePath : "/openclaw" ,
1104+ expectedPrefix : "/openclaw" ,
1105+ } ,
1106+ ] ) (
1107+ "anchors Vite-relative public asset hrefs for $name" ,
1108+ async ( { requestPath, basePath, expectedPrefix } ) => {
1109+ const assets = [
1110+ "favicon.svg" ,
1111+ "favicon-32.png" ,
1112+ "apple-touch-icon.png" ,
1113+ "manifest.webmanifest" ,
1114+ ] ;
1115+ const html = `<html><head>${ assets
1116+ . map ( ( asset ) => `<link href="./${ asset } " />` )
1117+ . join ( "" ) } </head><body></body></html>\n`;
1118+
1119+ await withControlUiRoot ( {
1120+ indexHtml : html ,
1121+ fn : async ( tmp ) => {
1122+ const { res, end } = makeMockHttpResponse ( ) ;
1123+ const handled = await handleControlUiHttpRequest (
1124+ { url : requestPath , method : "GET" } as IncomingMessage ,
1125+ res ,
1126+ {
1127+ ...( basePath ? { basePath } : { } ) ,
1128+ root : { kind : "resolved" , path : tmp } ,
1129+ } ,
1130+ ) ;
1131+
1132+ expect ( handled ) . toBe ( true ) ;
1133+ const body = String ( end . mock . calls [ 0 ] ?. [ 0 ] ?? "" ) ;
1134+ for ( const asset of assets ) {
1135+ expect ( body ) . toContain ( `href="${ expectedPrefix } /${ asset } "` ) ;
1136+ expect ( body ) . not . toContain ( `href="./${ asset } "` ) ;
1137+ }
1138+ } ,
1139+ } ) ;
1140+ } ,
1141+ ) ;
1142+
10931143 it ( "serves bootstrap config JSON" , async ( ) => {
10941144 await withControlUiRoot ( {
10951145 fn : async ( tmp ) => {
0 commit comments