@@ -181,6 +181,31 @@ window.addEventListener('popstate', parseURL);
181181// --- Core Logic ---
182182
183183function parseURL ( ) {
184+ // Check for repo_path query parameter (from 404.html redirect)
185+ const urlParams = new URLSearchParams ( window . location . search ) ;
186+ const repoPathParam = urlParams . get ( 'repo_path' ) ;
187+
188+ if ( repoPathParam ) {
189+ // We have a repository path from 404.html redirect
190+ const pathMatch = repoPathParam . match ( / \/ r e p o \/ ( [ ^ \/ ] + ) \/ ( [ ^ \/ ] + ) \/ ( [ ^ \/ ] + ) \/ ? $ / ) ;
191+
192+ if ( pathMatch ) {
193+ const [ , user , repo , branch ] = pathMatch ;
194+ const fullRepo = `${ user } /${ repo } ` ;
195+
196+ // Update the URL to the canonical form without query parameters
197+ history . replaceState ( null , null , repoPathParam ) ;
198+
199+ // Set input values and fetch the repository
200+ if ( repoInput && branchInput ) {
201+ repoInput . value = fullRepo ;
202+ branchInput . value = branch ;
203+ setTimeout ( ( ) => fetchRepoTree ( ) , 100 ) ; // Small delay to ensure UI is ready
204+ }
205+ return ; // Skip the rest of parseURL
206+ }
207+ }
208+
184209 // Skip URL parsing for specific pages we want to preserve
185210 const specialPages = [ '/featured-repos' , '/featured-repos.html' ] ;
186211 if ( specialPages . includes ( window . location . pathname ) ) {
@@ -196,7 +221,7 @@ function parseURL() {
196221 return ; // Don't process URLs for special pages
197222 }
198223
199- const urlParams = new URLSearchParams ( window . location . search ) ;
224+ // Check if using legacy parameter URLs (repo and branch parameters)
200225 const repoFromUrl = urlParams . get ( 'repo' ) ; // Already decoded by URLSearchParams
201226 const branchFromUrl = urlParams . get ( 'branch' ) ; // Already decoded
202227
0 commit comments