refactor(plugins): update search plugin

This commit is contained in:
qingwei.li 2017-02-19 10:47:47 +08:00 • committed by cinwell.li
commit 079bd00395
22 changed files with 348 additions and 393 deletions

View file

@ -1,5 +1,6 @@
import { merge, cached } from '../util/core'
import { parseQuery, stringifyQuery, cleanPath } from './util'
export * from './util'
function replaceHash (path) {
const i = window.location.href.indexOf('#')

View file

@ -1,10 +1,9 @@
import { normalize, parse } from './hash'
import { getBasePath, getPath } from './util'
import { getBasePath, getPath, isAbsolutePath } from './util'
import { on } from '../util/dom'
function getAlias (path, alias) {
if (alias[path]) return getAlias(alias[path], alias)
return path
return alias[path] ? getAlias(alias[path], alias) : path
}
function getFileName (path) {
@ -24,7 +23,7 @@ export function routeMixin (proto) {
path = getAlias(path, config.alias)
path = getFileName(path)
path = path === '/README.md' ? (config.homepage || path) : path
path = getPath(base, path)
path = isAbsolutePath(path) ? path : getPath(base, path)
return path
}

View file

@ -25,7 +25,7 @@ export function stringifyQuery (obj) {
const qs = []
for (const key in obj) {
qs.push(`${encode(key)}=${encode(obj[key])}`)
qs.push(`${encode(key)}=${encode(obj[key])}`.toLowerCase())
}
return qs.length ? `?${qs.join('&')}` : ''
@ -41,8 +41,8 @@ export function getPath (...args) {
return cleanPath(args.join('/'))
}
export const isResolvePath = cached(path => {
return /:|(\/{2})/.test(path)
export const isAbsolutePath = cached(path => {
return /(:|(\/{2}))/.test(path)
})
export const getRoot = cached(path => {