浏览代码

Docs: Ensure URLs without .html are properly redirected.

Mugen87 4 年之前
父节点
当前提交
c987adac58
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      docs/page.js

+ 3 - 1
docs/page.js

@@ -17,7 +17,9 @@ if ( ! window.frameElement && window.location.protocol !== 'file:' ) {
 
 
 	}
 	}
 
 
-	const pathSnippet = href.slice( splitIndex, - 5 );
+	const extension = href.split( '.' ).pop();
+	const end = ( extension === 'html' ) ? - 5 : href.length;
+	const pathSnippet = href.slice( splitIndex, end );
 
 
 	window.location.replace( docsBaseURL + '#' + pathSnippet + hash );
 	window.location.replace( docsBaseURL + '#' + pathSnippet + hash );