From: Eduardo San Martin Morote Date: Tue, 28 Apr 2020 20:03:07 +0000 (+0200) Subject: test: distance -> delta X-Git-Tag: v4.0.0-alpha.8~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fea638229f58159a4b3a116e0bc1662952c05e05;p=thirdparty%2Fvuejs%2Frouter.git test: distance -> delta --- diff --git a/__tests__/history/memory.spec.ts b/__tests__/history/memory.spec.ts index bd079ef4..15711cee 100644 --- a/__tests__/history/memory.spec.ts +++ b/__tests__/history/memory.spec.ts @@ -114,14 +114,14 @@ describe('Memory history', () => { expect(spy).toHaveBeenCalledTimes(1) expect(spy).toHaveBeenCalledWith(START, normalizedLoc, { direction: 'back', - distance: -1, + delta: -1, type: 'pop', }) history.go(1) expect(spy).toHaveBeenCalledTimes(2) expect(spy).toHaveBeenLastCalledWith(normalizedLoc, START, { direction: 'forward', - distance: 1, + delta: 1, type: 'pop', }) }) diff --git a/src/history/common.ts b/src/history/common.ts index f5a6abef..aaa72afc 100644 --- a/src/history/common.ts +++ b/src/history/common.ts @@ -1,4 +1,5 @@ import { isBrowser } from '../utils' +import { removeTrailingSlash } from '../location' interface HistoryLocation { fullPath: string @@ -167,5 +168,5 @@ export function normalizeBase(base?: string): string { // remove the trailing slash so all other method can just do `base + fullPath` // to build an href - return base.replace(/\/$/, '') + return removeTrailingSlash(base) } diff --git a/src/location.ts b/src/location.ts index a0b9dc7c..677252da 100644 --- a/src/location.ts +++ b/src/location.ts @@ -27,6 +27,10 @@ interface LocationPartial { hash?: string } +const TRAILING_SLASH_RE = /\/$/ +export const removeTrailingSlash = (path: string) => + path.replace(TRAILING_SLASH_RE, '') + /** * Transforms an URI into a normalized history location *