File tree 4 files changed +21
-7
lines changed
4 files changed +21
-7
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
+ ## 0.2.2 (2024-01-05)
4
+
5
+ - Feat: allow passing Router instance to ` getNextPath ` .
6
+
7
+ ## 0.2.1 (2024-01-05)
8
+
9
+ - Fix: package.json is now more Vite -compatible.
10
+
3
11
## 0.2.0 (2024-01-05)
4
12
5
- - Feat: added ` getNextPath `
6
- - Refactor: refactored internals
13
+ - Feat: added ` getNextPath ` .
14
+ - Refactor: refactored internals.
7
15
- Chore: bumped deps.
8
16
9
17
## 0.1.2 (2023-07-17)
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ General utilities for Web development
14
14
15
15
### Vue
16
16
17
- - ` getNextPath(): string ` - returns the value of ` ?next ` query param or ` / `
17
+ - ` getNextPath(router?: Router ): string ` - returns the value of ` ?next ` query param or ` / `
18
18
19
19
## Installation
20
20
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @slipmatio/toolbelt" ,
3
3
"type" : " module" ,
4
- "version" : " 0.2.1 " ,
4
+ "version" : " 0.2.2 " ,
5
5
"main" : " dist/toolbelt.umd.cjs" ,
6
6
"module" : " dist/toolbelt.js" ,
7
7
"exports" : {
Original file line number Diff line number Diff line change 1
- import { useRoute } from 'vue-router'
1
+ import { useRoute , type Router , type RouteLocationNormalizedLoaded } from 'vue-router'
2
2
import { isString } from './type-helpers'
3
3
4
4
/**
5
5
* Helper for figuring our ?next= query param in a safe way.
6
+ * Pass the router instance whenever not used directly from script setup block.
6
7
*/
7
- export function getNextPath ( ) : string {
8
- const route = useRoute ( )
8
+ export function getNextPath ( router ?: Router ) : string {
9
+ let route : RouteLocationNormalizedLoaded
10
+ if ( router ) {
11
+ route = router . currentRoute . value
12
+ } else {
13
+ route = useRoute ( )
14
+ }
9
15
10
16
let next = '/'
11
17
if (
You can’t perform that action at this time.
0 commit comments