Skip to content

Commit

Permalink
Merge pull request #481 from digitalnsw/update/docs-custom-url
Browse files Browse the repository at this point in the history
Adds link sanitisation for all navLinks making solution environment agnostic
  • Loading branch information
oisa authored Oct 18, 2024
2 parents b7eeac6 + f1bb705 commit c170a41
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/docs/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ function initDocs() {

navLinks.forEach((link) => {
let linkURL = link.getAttribute('href')
if (linkURL == '/') linkURL = '/home/index.html'
const sanitisedURL = new URL(linkURL, window.location.origin)
linkURL = sanitisedURL.pathname + sanitisedURL.search + sanitisedURL.hash

if (linkURL === '/') linkURL = '/home/index.html'

if (currentURL.match(linkURL)) {
link.classList.add('current')

Expand Down

0 comments on commit c170a41

Please sign in to comment.