@@ -78,33 +78,42 @@ export const GET = API(async (request, { db, user, origin, url, domain, payload
78
78
}
79
79
80
80
for ( const d of filteredDomains ) {
81
- if ( d . endsWith ( '.do' ) ) {
82
- let isInCategory = false
83
- for ( const sites of Object . values ( siteCategories ) ) {
84
- if ( sites . includes ( d ) ) {
85
- isInCategory = true
86
- break
87
- }
88
- }
89
-
90
- if ( ! isInCategory ) {
91
- const siteName = d . replace ( '.do' , '' )
92
- const description = getDomainDescription ( d ) || ''
93
- const siteTitle = `${ titleCase ( siteName ) } ${ description ? ` - ${ description } ` : '' } `
94
-
95
- let category = 'Other'
81
+ if ( typeof d !== 'string' ) {
82
+ console . error ( `Invalid domain encountered: ${ d } ` , typeof d )
83
+ continue
84
+ }
96
85
97
- if ( collectionSlugs . includes ( siteName ) ) {
98
- category = 'Collections'
99
- if ( ! formattedSites [ 'Collections' ] ) {
100
- formattedSites [ 'Collections' ] = { }
86
+ if ( d . endsWith ( '.do' ) ) {
87
+ try {
88
+ let isInCategory = false
89
+ for ( const sites of Object . values ( siteCategories ) ) {
90
+ if ( sites . includes ( d ) ) {
91
+ isInCategory = true
92
+ break
101
93
}
102
94
}
103
95
104
- if ( ! formattedSites [ category ] ) {
105
- formattedSites [ category ] = { }
96
+ if ( ! isInCategory ) {
97
+ const siteName = d . replace ( '.do' , '' )
98
+ const description = getDomainDescription ( d ) || ''
99
+ const siteTitle = `${ titleCase ( siteName ) } ${ description ? ` - ${ description } ` : '' } `
100
+
101
+ let category = 'Other'
102
+
103
+ if ( collectionSlugs . includes ( siteName ) ) {
104
+ category = 'Collections'
105
+ if ( ! formattedSites [ 'Collections' ] ) {
106
+ formattedSites [ 'Collections' ] = { }
107
+ }
108
+ }
109
+
110
+ if ( ! formattedSites [ category ] ) {
111
+ formattedSites [ category ] = { }
112
+ }
113
+ formattedSites [ category ] [ siteTitle ] = formatWithOptions ( `sites/${ siteName } ` , d )
106
114
}
107
- formattedSites [ category ] [ siteTitle ] = formatWithOptions ( `sites/${ siteName } ` , d )
115
+ } catch ( error ) {
116
+ console . error ( `Error processing domain ${ d } :` , error )
108
117
}
109
118
}
110
119
}
0 commit comments