refactor(core): and markdown compiler
This commit is contained in:
parent
30da0d5d46
commit
fe88c154b0
12 changed files with 194 additions and 232 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { parseQuery } from './util'
|
||||
import { merge } from '../util/core'
|
||||
import { parseQuery, stringifyQuery, cleanPath } from './util'
|
||||
|
||||
function replaceHash (path) {
|
||||
const i = window.location.href.indexOf('#')
|
||||
|
|
@ -34,11 +35,11 @@ export function getHash () {
|
|||
}
|
||||
|
||||
/**
|
||||
* Parse the current url
|
||||
* Parse the url
|
||||
* @param {string} [path=window.location.herf]
|
||||
* @return {object} { path, query }
|
||||
*/
|
||||
export function parse () {
|
||||
let path = window.location.href
|
||||
export function parse (path = window.location.href) {
|
||||
let query = ''
|
||||
|
||||
const queryIndex = path.indexOf('?')
|
||||
|
|
@ -57,9 +58,14 @@ export function parse () {
|
|||
|
||||
/**
|
||||
* to URL
|
||||
* @param {String} path
|
||||
* @param {String} qs query string
|
||||
* @param {string} path
|
||||
* @param {object} qs query params
|
||||
*/
|
||||
export function toURL (path, qs) {
|
||||
export function toURL (path, params) {
|
||||
const route = parse(path)
|
||||
|
||||
route.query = merge({}, route.query, params)
|
||||
path = route.path + stringifyQuery(route.query)
|
||||
|
||||
return '#' + path
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue