Factor out getting basepath to utils fn

Co-authored-by Jared Scheib <jared.scheib@gmail.com>
Co-authored-by Brandon Farmer <bthesorceror@gmail.com>
pull/3144/head
Jared Scheib 2018-04-06 13:06:38 -07:00
parent 1e4c212f39
commit 4276e9c4bd
2 changed files with 9 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import configureStore from 'src/store/configureStore'
import {loadLocalStorage} from 'src/localStorage'
import {getRootNode} from 'src/utils/nodes'
import {getBasepath} from 'src/utils/basepath'
import App from 'src/App'
import {
@ -52,6 +53,8 @@ const errorsQueue = []
const rootNode = getRootNode()
const basepath = getBasepath()
declare global {
interface Window {
basepath: string
@ -59,7 +62,6 @@ declare global {
}
// Older method used for pre-IE 11 compatibility
const basepath = rootNode.getAttribute('data-basepath') || ''
window.basepath = basepath
const browserHistory = useRouterHistory(createHistory)({

6
ui/src/utils/basepath.ts Normal file
View File

@ -0,0 +1,6 @@
import {getRootNode} from 'src/utils/nodes'
export const getBasepath = () => {
const rootNode = getRootNode()
return rootNode.getAttribute('data-basepath') || ''
}