Break off query string when comparing url for sidebar

This commit is contained in:
Michael Howell 2025-04-21 12:03:17 -07:00
parent 566a42c4f7
commit 36fa0064de
2 changed files with 18 additions and 1 deletions

View File

@ -10,7 +10,7 @@ class MDBookSidebarScrollbox extends HTMLElement {
connectedCallback() {
this.innerHTML = '{{#toc}}{{/toc}}';
// Set the current, active page, and reveal it if it's hidden
let current_page = document.location.href.toString().split("#")[0];
let current_page = document.location.href.toString().split("#")[0].split("?")[0];
if (current_page.endsWith("/")) {
current_page += "index.html";
}

View File

@ -0,0 +1,17 @@
// This GUI test checks the active page sidebar highlight.
go-to: |DOC_PATH| + "index.html"
assert-text: ("mdbook-sidebar-scrollbox a.active", "Prefix Chapter")
go-to: |DOC_PATH| + "individual/index.html"
assert-text: ("mdbook-sidebar-scrollbox a.active", "3. Markdown Individual tags")
go-to: |DOC_PATH| + "index.html?highlight=test"
assert-text: ("mdbook-sidebar-scrollbox a.active", "Prefix Chapter")
go-to: |DOC_PATH| + "individual/index.html?highlight=test"
assert-text: ("mdbook-sidebar-scrollbox a.active", "3. Markdown Individual tags")