@@ -6,8 +6,10 @@ import { DecodedPayloadOutputComponent } from "@/features/decoder/components/dec
66import { JwtInputComponent } from "@/features/decoder/components/jwt-input.component" ;
77import { SecretKeyInputComponent } from "@/features/decoder/components/secret-key-input.component" ;
88import { useDecoderStore } from "@/features/decoder/services/decoder.store" ;
9- import { usePathname , useRouter , useSearchParams } from "next/navigation" ;
10- import { SupportedTokenHashParamValues } from "@/libs/config/project.constants" ;
9+ import { useRouter } from "next/navigation" ;
10+ import {
11+ SupportedTokenHashParamValues
12+ } from "@/libs/config/project.constants" ;
1113import { HomeDictionaryModel } from "@/features/localization/models/home-dictionary.model" ;
1214import { ClaimDescriptionVisibilityValues } from "@/features/common/values/claim-description-visibility.values" ;
1315import { useDebuggerStore } from "@/features/debugger/services/debugger.store" ;
@@ -39,8 +41,6 @@ export const TokenDecoderComponent: React.FC<TokenDecoderComponentProps> = ({
3941 headlineConfig,
4042} ) => {
4143 const isMounted = useRef ( false ) ;
42- const searchParams = useSearchParams ( ) ;
43- const pathname = usePathname ( ) ;
4444
4545 const router = useRouter ( ) ;
4646
@@ -51,25 +51,8 @@ export const TokenDecoderComponent: React.FC<TokenDecoderComponentProps> = ({
5151
5252 useEffect ( ( ) => {
5353 const handleHashChange = ( ) => {
54- const tokenParam =
55- searchParams . get ( "token" ) ||
56- searchParams . get ( "id_token" ) ||
57- searchParams . get ( "access_token" ) ||
58- searchParams . get ( "value" ) ;
59- const isHomePage = pathname === "/" ;
60- const hash = tokenParam
61- ? `token=${ tokenParam } `
62- : window . location . hash . substring ( 1 ) ;
63-
64- if ( tokenParam && isHomePage ) {
65- const currentParams = new URLSearchParams ( searchParams . toString ( ) ) ;
66- currentParams . delete ( "token" ) ;
67- currentParams . delete ( "id_token" ) ;
68- currentParams . delete ( "access_token" ) ;
69- currentParams . delete ( "value" ) ;
70- router . replace ( `${ pathname } #${ hash } ` ) ;
71- }
72- console . count ( "hash handler fired" ) ;
54+ console . count ( "hash handler fired" )
55+ const hash = window . location . hash . substring ( 1 ) ;
7356
7457 if ( hash . includes ( "debugger-io?token=" ) ) {
7558 const debugHash = window . location . hash
@@ -85,32 +68,34 @@ export const TokenDecoderComponent: React.FC<TokenDecoderComponentProps> = ({
8568 }
8669
8770 const newUrl = `${ currentUrl } #${ SupportedTokenHashParamValues . TOKEN } =${ token } ` ;
88- console . log ( "Logging hash length before replacing///" , token . length ) ;
71+ console . log ( "Logging hash length before replacing///" , token . length )
8972 window . location . replace ( newUrl ) ;
9073
9174 return ;
9275 }
9376
9477 if ( ! hash . includes ( "=" ) ) {
95- console . log ( "hash not includes =" ) ;
78+ console . log ( "hash not includes =" )
9679 return ;
9780 }
9881
82+
83+
9984 const hashParams = new URLSearchParams ( hash ) ;
100- console . log ( "Hash param keys!!!" , hashParams ) ;
85+ console . log ( "Hash param keys!!!" , hashParams )
10186 Object . values ( SupportedTokenHashParamValues ) . forEach ( ( hashParamKey ) => {
10287 const token = hashParams . get ( hashParamKey ) ;
10388
10489 if ( token ) {
105- console . count ( "handling jwt change" ) ;
106- console . log ( "The token is:///" , token ) ;
90+ console . count ( "handling jwt change" )
91+ console . log ( "The token is:///" , token )
10792 handleJwtChange$ ( token ) ;
10893 }
10994 } ) ;
11095 } ;
11196
11297 window . addEventListener ( "hashchange" , handleHashChange ) ;
113-
98+
11499 handleHashChange ( ) ;
115100
116101 return ( ) => {
0 commit comments