Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
blockscout/apps/block_scout_web/assets/js/router.js

20 lines
731 B

import Path from 'path-parser'
import URI from 'urijs'
import humps from 'humps'
const { locale } = Path.createPath('/:locale').partialTest(window.location.pathname) || { locale: 'en' }
export default {
locale,
when (pattern, { exactPathMatch } = { exactPathMatch: false }) {
return new Promise((resolve) => {
const path = Path.createPath(`/:locale${pattern}`)
const match = exactPathMatch ? path.test(window.location.pathname) : path.partialTest(window.location.pathname)
if (match) {
const routeParams = humps.camelizeKeys(match)
const queryParams = humps.camelizeKeys(URI(window.location).query(true))
resolve(Object.assign({}, queryParams, routeParams))
}
})
}
}