@@ -21,35 +21,20 @@ export function useParseRouter(appId: number | null) {
2121 refreshApp,
2222 } = useLoadApp ( appId ) ;
2323
24- // Detect Next.js app by presence of next.config.* in file list
25- const isNextApp = useMemo ( ( ) => {
26- if ( ! app ?. files ) return false ;
27- return app . files . some ( ( f ) => f . toLowerCase ( ) . includes ( "next.config" ) ) ;
28- } , [ app ?. files ] ) ;
29-
30- // Detect Vue app by presence of .vue files in src/ or frontend/src/
31- const isVueApp = useMemo ( ( ) => {
32- if ( ! app ?. files ) return false ;
33- return app . files . some ( ( f ) => f . includes ( '.vue' ) ) ;
34- } , [ app ?. files ] ) ;
35-
3624 // Load router related file to extract routes for non-Next apps
37- // For Vue apps, try .vue files; for React/other, try .tsx files
38- const primaryRouterPath = isVueApp ? "frontend/src/App.vue" : "frontend/src/App.tsx" ;
39- const fallbackRouterPath = isVueApp ? "src/App.vue" : "src/App.tsx" ;
40-
25+ // First try frontend/src/App.tsx (new structure), then fallback to src/App.tsx
4126 const {
4227 content : frontendRouterContent ,
4328 loading : frontendRouterFileLoading ,
4429 error : frontendRouterFileError ,
45- } = useLoadAppFile ( appId , primaryRouterPath ) ;
30+ } = useLoadAppFile ( appId , "frontend/src/App.tsx" ) ;
4631
4732 const {
4833 content : routerContent ,
4934 loading : routerFileLoading ,
5035 error : routerFileError ,
5136 refreshFile,
52- } = useLoadAppFile ( appId , fallbackRouterPath ) ;
37+ } = useLoadAppFile ( appId , "src/App.tsx" ) ;
5338
5439 const {
5540 content : vueRouterContent ,
@@ -63,8 +48,6 @@ export function useParseRouter(appId: number | null) {
6348 error : vueAppError ,
6449 } = useLoadAppFile ( appId , "src/App.vue" ) ;
6550
66- < < < << << HEAD
67- = === ===
6851 // Detect Next.js app by presence of next.config.* in file list
6952 const isNextApp = useMemo ( ( ) => {
7053 if ( ! app ?. files ) return false ;
@@ -82,7 +65,6 @@ export function useParseRouter(appId: number | null) {
8265 const finalRouterLoading = frontendRouterFileLoading || routerFileLoading || ( isVueApp ? vueAppLoading : false ) ;
8366 const finalRouterError = frontendRouterFileError || routerFileError || ( isVueApp ? vueAppError : false ) ;
8467
85- >>> > >>> release / v0 .0 .5
8668 // Parse routes either from Next.js file-based routing or from router file
8769 useEffect ( ( ) => {
8870 const buildLabel = ( path : string ) =>
@@ -176,41 +158,16 @@ export function useParseRouter(appId: number | null) {
176158
177159 try {
178160 const parsedRoutes : ParsedRoute [ ] = [ ] ;
161+ const routePathsRegex = / < R o u t e \s + (?: [ ^ > ] * \s + ) ? p a t h = [ " ' ] ( [ ^ " ' ] + ) [ " ' ] / g;
162+ let match : RegExpExecArray | null ;
179163
180- if ( isVueApp ) {
181- // For Vue apps, look for route definitions in various formats
182- // Vue Router routes can be defined in different ways
183- const vueRouteRegexes = [
184- // Vue Router createRouter format: path: '/home'
185- / p a t h : \s * [ " ' ] ( [ ^ " ' ] + ) [ " ' ] / g,
186- // Vue Router route object: { path: '/home' }
187- / { [ ^ } ] * p a t h : \s * [ " ' ] ( [ ^ " ' ] + ) [ " ' ] [ ^ } ] * } / g,
188- ] ;
189-
190- for ( const regex of vueRouteRegexes ) {
191- let match : RegExpExecArray | null ;
192- while ( ( match = regex . exec ( content ) ) !== null ) {
193- const path = match [ 1 ] ;
194- const label = buildLabel ( path ) ;
195- if ( ! parsedRoutes . some ( ( r ) => r . path === path ) ) {
196- parsedRoutes . push ( { path, label } ) ;
197- }
198- }
199- }
200- } else {
201- // React-style route parsing
202- const routePathsRegex = / < R o u t e \s + (?: [ ^ > ] * \s + ) ? p a t h = [ " ' ] ( [ ^ " ' ] + ) [ " ' ] / g;
203- let match : RegExpExecArray | null ;
204-
205- while ( ( match = routePathsRegex . exec ( content ) ) !== null ) {
206- const path = match [ 1 ] ;
207- const label = buildLabel ( path ) ;
208- if ( ! parsedRoutes . some ( ( r ) => r . path === path ) ) {
209- parsedRoutes . push ( { path, label } ) ;
210- }
164+ while ( ( match = routePathsRegex . exec ( content ) ) !== null ) {
165+ const path = match [ 1 ] ;
166+ const label = buildLabel ( path ) ;
167+ if ( ! parsedRoutes . some ( ( r ) => r . path === path ) ) {
168+ parsedRoutes . push ( { path, label } ) ;
211169 }
212170 }
213-
214171 setRoutes ( parsedRoutes ) ;
215172 } catch ( e ) {
216173 console . error ( "Error parsing router file:" , e ) ;
0 commit comments