@@ -88,17 +88,14 @@ class CoCreateFileSystem {
8888
8989 const bcp47Regex = / ^ \/ ( [ a - z A - Z ] { 2 , 3 } (?: - [ a - z A - Z 0 - 9 ] { 2 , 8 } ) + ) \/ / ;
9090 const langMatch = pathname . match ( bcp47Regex ) ;
91- let lang , langRegion , basePathname , langPathname ;
91+ let lang , langRegion ;
9292 if ( langMatch ) {
9393 langRegion = langMatch [ 1 ] ;
9494 lang = langRegion . split ( "-" ) [ 0 ] ; // Get just the base language (e.g., 'en', 'es', 'fr')
95- basePathname = pathname . replace ( langRegion , "" ) ;
96- langPathname = pathname . replace ( langRegion , lang ) ;
97-
95+ let basePathname = pathname . replace ( langRegion , "" ) ;
9896 data . $filter . query . pathname = {
99- $in : [ pathname , langPathname , basePathname ]
97+ $in : [ basePathname ]
10098 } ;
101- data . $filter . limit = 3 ; // Increase limit to get all possible matches
10299 } else {
103100 data . $filter . query . pathname = pathname ;
104101 }
@@ -146,16 +143,7 @@ class CoCreateFileSystem {
146143 } ) ;
147144 }
148145
149- if ( langMatch && file . object . length > 1 ) {
150- // Prioritize exact match with full lang-region
151- file =
152- file . object . find ( ( f ) => f . pathname === pathname ) ||
153- file . object . find ( ( f ) => f . pathname === langPathname ) ||
154- file . object . find ( ( f ) => f . pathname === basePathname ) ||
155- file . object [ 0 ] ;
156- } else {
157- file = file . object [ 0 ] ;
158- }
146+ file = file . object [ 0 ] ;
159147 if ( ! file [ "public" ] || file [ "public" ] === "false" ) {
160148 let pageForbidden = await getDefaultFile ( "/403.html" ) ;
161149 return sendResponse ( pageForbidden . object [ 0 ] . src , 403 , {
@@ -210,7 +198,7 @@ class CoCreateFileSystem {
210198 file . urlObject = urlObject ;
211199
212200 if ( langRegion ) {
213- if ( file . languages ) {
201+ if ( ! file . languages ) {
214202 file . languages = organization . languages || [
215203 langRegion
216204 ] ;
0 commit comments