]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: distance -> delta
authorEduardo San Martin Morote <posva13@gmail.com>
Tue, 28 Apr 2020 20:03:07 +0000 (22:03 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Tue, 28 Apr 2020 20:03:07 +0000 (22:03 +0200)
__tests__/history/memory.spec.ts
src/history/common.ts
src/location.ts

index bd079ef426a3d5a021786f53fe75076cf62a8ba5..15711cee92b62b433fe78c0f467bd0e19546dacc 100644 (file)
@@ -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',
     })
   })
index f5a6abef4055530cecf56353e057b16ab32aac8d..aaa72afc56a48a182ac025cd429a52dddae5cfe4 100644 (file)
@@ -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)
 }
index a0b9dc7c879f39fafcdda3c92a96016bd72de059..677252da6f8310ad19d5186d523703ca7137cf23 100644 (file)
@@ -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
  *