feat: finish ssr

This commit is contained in:
qingwei.li 2017-05-30 00:23:43 +08:00 • committed by cinwell.li
commit 3444884905
12 changed files with 163 additions and 40 deletions

View file

@ -1,4 +1,5 @@
import { cached } from '../util/core'
import { inBrowser } from '../util/env'
const decode = decodeURIComponent
const encode = encodeURIComponent
@ -31,10 +32,13 @@ export function stringifyQuery (obj) {
return qs.length ? `?${qs.join('&')}` : ''
}
export const getBasePath = cached(base => {
export const getBasePath = cached((base = '') => {
// TODO
const path = inBrowser ? window.location.pathname : ''
return /^(\/|https?:)/g.test(base)
? base
: cleanPath(window.location.pathname + '/' + base)
: cleanPath(path + '/' + base)
})
export function getPath (...args) {