Fixes
This commit is contained in:
parent
e54ac03319
commit
658a783f6a
8 changed files with 29 additions and 24 deletions
|
|
@ -6,16 +6,24 @@ import FileUpload from './components/FileUpload';
|
|||
import NavBar from './components/modules/NavBar';
|
||||
import TextUpload from './components/TextUpload';
|
||||
import UrlShortener from './components/UrlShortener';
|
||||
import CheckUrlRedirect from './axios/getUrlHandler';
|
||||
|
||||
const slug = window.location.pathname.match(/[^/][^/]*/g);
|
||||
|
||||
export default () => {
|
||||
// Check to see if slug is worth trying :)
|
||||
!!slug && CheckUrlRedirect(slug).then((url) => {
|
||||
window.location.href = url;
|
||||
}).catch(() => {});
|
||||
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
<Router>
|
||||
<NavBar />
|
||||
<div style={{ paddingTop: `${3.5}em` }} />
|
||||
<Route exact path="/" component={UrlShortener} />
|
||||
<Route exact path="/f" component={FileUpload} />
|
||||
<Route exact path="/p" component={TextUpload} />
|
||||
<Route exact path="/code" component={TextUpload} />
|
||||
<Route exact path="/files" component={FileUpload} />
|
||||
</Router>
|
||||
</React.StrictMode>,
|
||||
document.getElementById('root'),
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import axios from 'axios';
|
||||
|
||||
export default (slug) => axios.get(`/p/${slug}`).then((resp) => resp.data);
|
||||
export default (slug) => axios.get(`/c/${slug}`).then((resp) => resp.data);
|
||||
|
|
|
|||
4
frontend/src/axios/getUrlHandler.js
Normal file
4
frontend/src/axios/getUrlHandler.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import axios from 'axios';
|
||||
|
||||
export default (slug) => axios.get(`/api/${slug}`)
|
||||
.then((resp) => resp.data);
|
||||
|
|
@ -83,7 +83,7 @@ export default () => {
|
|||
putTxtHandler(state).then((data) => {
|
||||
setState({
|
||||
...state,
|
||||
result: `${window.location.origin}/p?id=${data}`,
|
||||
result: `${window.location.origin}/code?id=${data}`,
|
||||
loading: false,
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export default () => {
|
|||
putUrlHandler(state.url).then((data) => {
|
||||
setState({
|
||||
...state,
|
||||
result: `${window.location.origin}/${data}`.replace('5000', '3000'),
|
||||
result: `${window.location.origin}/${data}`,
|
||||
loading: false,
|
||||
error: false,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ export default () => (
|
|||
<Navbar.Collapse>
|
||||
<Nav className="mr-auto">
|
||||
<NavLinkItem name="URL" dest="/" icon={faLink} />
|
||||
<NavLinkItem name="Code" dest="/p" icon={faCode} />
|
||||
<NavLinkItem name="File" dest="/f" icon={faFile} />
|
||||
<NavLinkItem name="Code" dest="/code" icon={faCode} />
|
||||
<NavLinkItem name="File" dest="/files" icon={faFile} />
|
||||
</Nav>
|
||||
</Navbar.Collapse>
|
||||
</Navbar>
|
||||
|
|
|
|||
Loading…
Reference in a new issue