Skip to content

Commit 12b4a96

Browse files
authored
Merge pull request #2675 from notriddle/sidebar/active-query
Break off query string when comparing url for sidebar
2 parents 566a42c + 36fa006 commit 12b4a96

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/front-end/templates/toc.js.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class MDBookSidebarScrollbox extends HTMLElement {
1010
connectedCallback() {
1111
this.innerHTML = '{{#toc}}{{/toc}}';
1212
// Set the current, active page, and reveal it if it's hidden
13-
let current_page = document.location.href.toString().split("#")[0];
13+
let current_page = document.location.href.toString().split("#")[0].split("?")[0];
1414
if (current_page.endsWith("/")) {
1515
current_page += "index.html";
1616
}

tests/gui/sidebar-active.goml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This GUI test checks the active page sidebar highlight.
2+
3+
go-to: |DOC_PATH| + "index.html"
4+
5+
assert-text: ("mdbook-sidebar-scrollbox a.active", "Prefix Chapter")
6+
7+
go-to: |DOC_PATH| + "individual/index.html"
8+
9+
assert-text: ("mdbook-sidebar-scrollbox a.active", "3. Markdown Individual tags")
10+
11+
go-to: |DOC_PATH| + "index.html?highlight=test"
12+
13+
assert-text: ("mdbook-sidebar-scrollbox a.active", "Prefix Chapter")
14+
15+
go-to: |DOC_PATH| + "individual/index.html?highlight=test"
16+
17+
assert-text: ("mdbook-sidebar-scrollbox a.active", "3. Markdown Individual tags")

0 commit comments

Comments
 (0)