-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd64e1f
commit 01228d8
Showing
4 changed files
with
45 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react' | ||
import config from 'config' | ||
import { parseMarketPair } from '@/utils/misc' | ||
|
||
export const getServerSideProps = async ({ req, res, params, }) => { | ||
const host = config.get('dex_service.host') | ||
const parsed = parseMarketPair(params.market_pair) | ||
if (!parsed.length) { | ||
return { | ||
notFound: true | ||
} | ||
} | ||
const url = new URL('/#/trade/' + parsed.join('_'), host) | ||
return { | ||
redirect: { | ||
destination: url.toString(), | ||
permanent: false, | ||
}, | ||
} | ||
} | ||
|
||
class TickerRedirect extends React.Component { | ||
render() { | ||
return null | ||
} | ||
} | ||
|
||
export default TickerRedirect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import config from 'config' | ||
|
||
const cfgSymbols = config.get('symbols') | ||
const cfgPairs = config.get('pairs') | ||
|
||
export const parseMarketPair = (pair) => { | ||
if (!cfgPairs.includes(pair)) { | ||
return [] | ||
} | ||
const [ base, quote ] = pair.split('_') | ||
return [ cfgSymbols.get(base)[0], cfgSymbols.get(quote)[0] ] | ||
} |