Skip to content

Commit

Permalink
fix matching for setting active navbar link
Browse files Browse the repository at this point in the history
  • Loading branch information
RVRX committed Jul 1, 2022
1 parent ea55326 commit c885a56
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions assets/js/torch.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ window.onload = () => {
slice.call(document.querySelectorAll('.torch-nav a'), 0).forEach((field) => {
const url = window.location.href
const linkTarget = field.getAttribute('href')
const regex = RegExp(linkTarget)
const linkTargetFullPath = new URL(linkTarget, document.baseURI).href

if (regex.test(url)) {
if (url === linkTargetFullPath) {
field.classList.add('active')
}
})
Expand Down

0 comments on commit c885a56

Please sign in to comment.