File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed
src_assets/common/assets/web Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -41,15 +41,28 @@ <h1 class="mb-2">
41
41
methods : {
42
42
onLogin ( ) {
43
43
const searchParams = new URLSearchParams ( window . location . search ) ;
44
- let newPath = '/' ;
44
+ let newPath ;
45
45
if ( searchParams . has ( 'redirect' ) ) {
46
46
const redirect = searchParams . get ( 'redirect' ) ;
47
- if ( redirect . startsWith ( '/' ) ) {
48
- newPath = redirect ;
49
- } else {
50
- newPath = newPath + redirect ;
47
+ const encodePath = ( path ) => {
48
+ return path . split ( '' ) . map ( char => {
49
+ if ( char === '/' ) return char ; // Keep '/' unencoded
50
+ return encodeURIComponent ( char ) ;
51
+ } ) . join ( '' ) ;
52
+ } ;
53
+
54
+ try {
55
+ const redirectUrl = new URL ( redirect ) ;
56
+ newPath = redirectUrl . pathname ;
57
+ } catch ( error ) {
58
+ if ( redirect . startsWith ( '/' ) ) {
59
+ newPath = encodePath ( redirect ) ;
60
+ } else {
61
+ newPath = '/' ;
62
+ }
51
63
}
52
64
}
65
+
53
66
document . location . href = newPath ;
54
67
}
55
68
}
You can’t perform that action at this time.
0 commit comments