@@ -487,6 +487,45 @@ describe("Navigation Marker", function () {
487487 ) ;
488488 expect ( news_link . parentElement . classList . contains ( "inPath" ) ) . toBe ( false ) ;
489489 } ) ;
490+
491+ it ( "handles URL rebasing correctly" , async function ( ) {
492+ // Test absolute URLs that should work directly
493+ const canonical_link = document . querySelector ( 'head link[rel="canonical"]' ) ;
494+ canonical_link . href = "http://example.com/site/news/article-1" ;
495+
496+ // Set a portal URL
497+ document . body . dataset . portalUrl = "http://example.com/site" ;
498+
499+ document . body . innerHTML = `
500+ <nav class="pat-navigationmarker">
501+ <ul>
502+ <li><a href="http://example.com/site">Home</a></li>
503+ <li><a href="http://example.com/site/news">News</a></li>
504+ <li><a href="http://example.com/site/news/article-1">Article 1</a></li>
505+ </ul>
506+ </nav>
507+ ` ;
508+
509+ this . nav_element = document . querySelector ( ".pat-navigationmarker" ) ;
510+ registry . scan ( document . body ) ;
511+ await utils . timeout ( 1 ) ;
512+
513+ // Test with absolute URLs that match the canonical structure
514+ const article_link = this . nav_element . querySelector (
515+ "a[href='http://example.com/site/news/article-1']" ,
516+ ) ;
517+ const news_link = this . nav_element . querySelector (
518+ "a[href='http://example.com/site/news']" ,
519+ ) ;
520+ const home_link = this . nav_element . querySelector (
521+ "a[href='http://example.com/site']" ,
522+ ) ;
523+
524+ expect ( article_link . classList . contains ( "current" ) ) . toBe ( true ) ;
525+ expect ( news_link . parentElement . classList . contains ( "inPath" ) ) . toBe ( true ) ;
526+ // Home should not be in-path since we're on a sub-page
527+ expect ( home_link . parentElement . classList . contains ( "inPath" ) ) . toBe ( false ) ;
528+ } ) ;
490529} ) ;
491530
492531describe ( "Navigation Marker - Portal URL Edge Cases" , function ( ) {
0 commit comments