From: Eduardo San Martin Morote Date: Tue, 16 Apr 2019 15:17:05 +0000 (+0200) Subject: feat allow relative navigation with query or hash params X-Git-Tag: v4.0.0-alpha.0~441 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4243e2eaa75dbb731969ad7124298988e4a0708;p=thirdparty%2Fvuejs%2Frouter.git feat allow relative navigation with query or hash params --- diff --git a/src/history/utils.ts b/src/history/utils.ts index d3eb2900..0df4ede8 100644 --- a/src/history/utils.ts +++ b/src/history/utils.ts @@ -3,6 +3,7 @@ import { HistoryQuery, HistoryLocation, } from './base' +import { RouteQuery } from '../types' const PERCENT_RE = /%/g @@ -108,6 +109,11 @@ export function stringifyQuery(query: HistoryQuery): string { return search } +export function normalizeQuery(query: RouteQuery): HistoryQuery { + // TODO: implem + return query as HistoryQuery +} + /** * Prepare a URI string to be passed to pushState * @param uri diff --git a/src/router.ts b/src/router.ts index 1f15d77d..d874252f 100644 --- a/src/router.ts +++ b/src/router.ts @@ -51,7 +51,11 @@ export class Router { // named or relative route // we need to resolve first location = this.matcher.resolve(to, this.currentRoute) - url = this.history.utils.normalizeLocation(location) + url = this.history.utils.normalizeLocation({ + query: this.history.utils.normalizeQuery(to.query || {}), + hash: to.hash, + ...location, + }) } // TODO: call hooks, guards