@@ -129,6 +129,7 @@ export class IncludeProcessor {
129129 let aliased = false ;
130130
131131 if ( isRequire ) {
132+ filename = this . normalizeRequirePath ( filename ) ;
132133 if ( ! filename . startsWith ( "@" ) ) {
133134 // Regular require, relative lookup
134135 includePaths = [ "." ] ;
@@ -324,6 +325,15 @@ export class IncludeProcessor {
324325 } ;
325326 }
326327
328+ private normalizeRequirePath ( filename : string ) : string {
329+ if ( ! filename . includes ( path . sep ) ) {
330+ filename = filename . split ( "/" ) . join ( path . sep ) ;
331+ }
332+ const dbl = path . sep + path . sep ;
333+ while ( filename . includes ( dbl ) ) filename = filename . split ( dbl ) . join ( path . sep ) ;
334+ return filename ;
335+ }
336+
327337 private async getLuauRequireAliasDir ( requirePath :string , sourceFile :NormalizedPath , state :IncludeState ) : Promise < string > {
328338 if ( ! requirePath . startsWith ( "@" ) ) {
329339 throw "Alias must start with @" ;
@@ -353,9 +363,13 @@ export class IncludeProcessor {
353363 private async resolveLuaurcFileAliases ( sourceFile :string , rcMap : LuauRCRequireMap ) : Promise < RequireMap > {
354364 const map : RequireMap = { } ;
355365 let dir = normalizePath ( sourceFile ) ;
356- while ( true ) {
366+ let last = dir ;
367+ let limit = 25 ;
368+ while ( limit -- > 0 ) {
357369 dir = normalizePath ( path . dirname ( dir ) ) ;
358- if ( dir . length < 3 ) break ;
370+ if ( last == dir ) {
371+ break ;
372+ }
359373 const norm = normalizeJoinPath ( dir , ".luaurc" ) ;
360374 let dirMap = rcMap [ norm ] ?? null ;
361375 if ( ! dirMap ) {
0 commit comments