Skip to content

Commit 4981e2d

Browse files
committed
Use Location API
1 parent 117731e commit 4981e2d

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/components/Header/Header.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,10 @@ const componentClass = "rvt-header";
2323
const HeaderComponent: React.SFC<HeaderProps & React.HTMLAttributes<HTMLDivElement>> = ({ children, className, title, ...attrs }) => {
2424
const identity = findFirstChildOfType(children, Identity.displayName);
2525
const navigation = findFirstChildOfType(children, Navigation.displayName);
26-
let mainContentUrl = document.URL;
27-
const anchorCharacter = '#';
28-
if (mainContentUrl.indexOf(anchorCharacter) >= 0) {
29-
mainContentUrl = mainContentUrl.split(/\s?(#[a-zA-Z0-9-]+)/).filter(string => !string.startsWith(anchorCharacter)).join('');;
30-
}
3126

3227
return (
3328
<header {...attrs} className={classNames(componentClass, className)} role="banner">
34-
<a className="rvt-skip-link" href={`${mainContentUrl}${anchorCharacter}main-content`}>Skip to content</a>
29+
<a className="rvt-skip-link" href={`${window.location.pathname}#main${window.location.search ? '?' + window.location.search : ''}`}>Skip to content</a>
3530
<div className="rvt-header__trident">
3631
<Icon name="trident-header" />
3732
</div>

0 commit comments

Comments
 (0)