From ecc452131417c888165c7e4918d963c103cfbf16 Mon Sep 17 00:00:00 2001 From: Griffithtp Date: Sun, 14 Jul 2019 12:35:57 +0100 Subject: [PATCH] refactor: remove getBaseNamePath() and history.ts --- src/history.ts | 8 -------- src/router.tsx | 6 +++++- src/utils/url.ts | 8 -------- 3 files changed, 5 insertions(+), 17 deletions(-) delete mode 100644 src/history.ts diff --git a/src/history.ts b/src/history.ts deleted file mode 100644 index a8f41b8..0000000 --- a/src/history.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { createBrowserHistory } from 'history'; -import { getBaseNamePath } from './utils/url'; - -const history = createBrowserHistory({ - basename: getBaseNamePath(), -}); - -export default history; diff --git a/src/router.tsx b/src/router.tsx index dcc0e2b..394b8ee 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -2,12 +2,16 @@ import React, { Component, ReactElement } from 'react'; import { Router, Route, Switch } from 'react-router-dom'; +import { createBrowserHistory } from 'history'; import { AppContextConsumer, AppStateInterface } from './App/App'; import { asyncComponent } from './utils/asyncComponent'; -import history from './history'; import Header from './components/Header'; +const history = createBrowserHistory({ + basename: window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.url_prefix, +}); + const NotFound = asyncComponent(() => import('./components/NotFound')); const VersionPackage = asyncComponent(() => import('./pages/version/Version')); const HomePage = asyncComponent(() => import('./pages/home')); diff --git a/src/utils/url.ts b/src/utils/url.ts index 119888e..d428410 100644 --- a/src/utils/url.ts +++ b/src/utils/url.ts @@ -18,11 +18,3 @@ export function getRegistryURL(): string { // Don't add slash if it's not a sub directory return `${location.origin}${location.pathname === '/' ? '' : location.pathname}`; } - -export function getBaseNamePath(): string { - return window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.url_prefix; -} - -export function getRootPath(): string { - return window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.base; -}