@@ -441,21 +441,31 @@ class Sidebar {
441
441
_setActiveLink ( ) {
442
442
// eslint-disable-next-line unicorn/prefer-spread
443
443
Array . from ( this . _element . querySelectorAll ( SELECTOR_NAV_LINK ) ) . forEach ( element => {
444
- let currentUrl
444
+ let currentUrl = String ( window . location )
445
445
446
- const urlHasParams = / \\ ? .* = /
447
- const urlHasQueryString = / \\ ? ./
446
+ const urlHasParams = / \? .* = /
447
+ const urlHasQueryString = / \? ./
448
448
const urlHasHash = / # ./
449
449
450
- if ( urlHasParams . test ( String ( window . location ) ) || urlHasQueryString . test ( String ( window . location ) ) ) {
451
- currentUrl = String ( window . location ) . split ( '?' ) [ 0 ]
452
- } else if ( urlHasHash . test ( String ( window . location ) ) ) {
453
- currentUrl = String ( window . location ) . split ( '#' ) [ 0 ]
454
- } else {
455
- currentUrl = String ( window . location )
450
+ console . log ( urlHasHash . test ( String ( window . location ) ) )
451
+
452
+ if ( urlHasParams . test ( currentUrl ) || urlHasQueryString . test ( currentUrl ) ) {
453
+ currentUrl = currentUrl . split ( '?' ) [ 0 ]
456
454
}
457
455
458
- if ( currentUrl . slice ( - 1 ) === '#' ) {
456
+ if ( urlHasHash . test ( currentUrl ) ) {
457
+ currentUrl = currentUrl . split ( '#' ) [ 0 ]
458
+ }
459
+
460
+ // if (urlHasParams.test(String(window.location)) || urlHasQueryString.test(String(window.location))) {
461
+ // currentUrl = String(window.location).split('?')[0]
462
+ // } else if (urlHasHash.test(String(window.location))) {
463
+ // currentUrl = String(window.location).split('#')[0]
464
+ // } else {
465
+ // currentUrl = String(window.location)
466
+ // }
467
+
468
+ if ( currentUrl . slice ( - 1 ) === '#' ) {
459
469
currentUrl = currentUrl . slice ( 0 , - 1 )
460
470
}
461
471
0 commit comments