parent
836ee81b2f
commit
a00ab92179
@ -0,0 +1,19 @@ |
|||||||
|
import Path from 'path-parser' |
||||||
|
import URI from 'urijs' |
||||||
|
import humps from 'humps' |
||||||
|
|
||||||
|
const { locale } = Path.createPath('/:locale').partialTest(window.location.pathname) |
||||||
|
|
||||||
|
export default { |
||||||
|
locale, |
||||||
|
when (pattern) { |
||||||
|
return new Promise((resolve) => { |
||||||
|
const match = Path.createPath(`/:locale${pattern}`).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)) |
||||||
|
} |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
@ -1,6 +1,7 @@ |
|||||||
import {Socket} from 'phoenix' |
import {Socket} from 'phoenix' |
||||||
|
import router from './router' |
||||||
|
|
||||||
const socket = new Socket('/socket', {params: {locale: window.locale}}) |
const socket = new Socket('/socket', {params: {locale: router.locale}}) |
||||||
socket.connect() |
socket.connect() |
||||||
|
|
||||||
export default socket |
export default socket |
||||||
|
Loading…
Reference in new issue