Skip to content

Commit

Permalink
fix(v2): remove trailing slash from router links
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 committed Mar 25, 2020
1 parent 27e7fa6 commit 08232ea
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/docusaurus/src/client/exports/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ import React, {useEffect, useRef} from 'react';
import {NavLink} from 'react-router-dom';
import isInternalUrl from '@docusaurus/isInternalUrl';
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
import {useLocation} from '@docusaurus/router';

function Link(props) {
const {to, href} = props;
const targetLink = to || href;
const isInternal = isInternalUrl(targetLink);
const preloaded = useRef(false);
const location = useLocation();
// Change the current state of location by removing trailing slash from its pathname.
location.pathname = location.pathname.replace(/\/$/, '');

const IOSupported = ExecutionEnvironment.canUseIntersectionObserver;

Expand Down

0 comments on commit 08232ea

Please sign in to comment.