Extract windows location code into hook (#808)

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
Tilman Vatteroth 2020-11-30 10:09:04 +01:00 committed by GitHub
parent a24ef18dd4
commit bc7ff07256
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View file

@ -0,0 +1,13 @@
/*
SPDX-FileCopyrightText: 2020 The HedgeDoc developers (see AUTHORS file)
SPDX-License-Identifier: AGPL-3.0-only
*/
import { useLocation } from 'react-router'
export const useFrontendBaseUrl = (): string => {
const { pathname } = useLocation()
return window.location.pathname.replace(pathname, '')
}