@@ -337,8 +337,12 @@ export function relativeOutputPath(url: string, siteUrl: string): string {
337337 const sitePath = new URL ( normalizeSiteUrl ( siteUrl ) ) . pathname . replace ( / \/ + $ / , '' ) ;
338338 let parsedPath = new URL ( url ) . pathname ;
339339
340+ if ( sitePath && parsedPath === sitePath ) {
341+ return ROOT_OUTPUT_PATH ;
342+ }
340343 if ( sitePath && parsedPath . startsWith ( `${ sitePath } /` ) ) {
341344 parsedPath = parsedPath . slice ( sitePath . length + 1 ) ;
345+ if ( ! parsedPath ) return ROOT_OUTPUT_PATH ;
342346 } else {
343347 parsedPath = parsedPath . replace ( / ^ \/ + / , '' ) ;
344348 }
@@ -661,10 +665,10 @@ function normalizeOutputPath(path: string): string {
661665 }
662666
663667 value = value . replace ( / ^ \/ + / , '' ) . replace ( / \/ + $ / , '' ) ;
664- if ( ! value ) return '' ;
668+ if ( ! value ) return ROOT_OUTPUT_PATH ;
665669 if ( value . endsWith ( '.html' ) ) value = value . slice ( 0 , - 5 ) ;
666670 else if ( value . endsWith ( '.htm' ) ) value = value . slice ( 0 , - 4 ) ;
667- if ( value === 'index' ) return '' ;
671+ if ( value === ROOT_OUTPUT_PATH ) return ROOT_OUTPUT_PATH ;
668672 if ( value . endsWith ( '/index' ) ) value = value . slice ( 0 , - '/index' . length ) ;
669673 return value ;
670674}
@@ -723,6 +727,7 @@ const HEAD_RE = /<head\b.*?<\/head>/gis;
723727const SCRIPT_STYLE_RE = / < (?: s c r i p t | s t y l e ) \b .* ?> .* ?< \/ (?: s c r i p t | s t y l e ) > / gis;
724728const TAG_RE = / < [ ^ > ] + > / g;
725729const WHITESPACE_RE = / \s + / g;
730+ const ROOT_OUTPUT_PATH = 'index' ;
726731const STOPWORDS = new Set ( [
727732 'a' ,
728733 'an' ,
0 commit comments