@@ -64,7 +64,8 @@ function findPath(request, paths, isMain, fields, exts) {
64
64
65
65
if ( isAbs ) {
66
66
paths = [ "" ]
67
- } else if ( ! paths || ! paths . length ) {
67
+ } else if ( ! Array . isArray ( paths ) ||
68
+ paths . length === 0 ) {
68
69
return ""
69
70
}
70
71
@@ -89,7 +90,8 @@ function findPath(request, paths, isMain, fields, exts) {
89
90
: resolveSymlinks
90
91
91
92
for ( let curPath of paths ) {
92
- if ( curPath &&
93
+ if ( typeof curPath === "string" &&
94
+ curPath . length > 0 &&
93
95
statFast ( curPath ) !== 1 ) {
94
96
continue
95
97
}
@@ -102,7 +104,7 @@ function findPath(request, paths, isMain, fields, exts) {
102
104
103
105
curPath = realpath ( curPath )
104
106
105
- if ( ! curPath ) {
107
+ if ( curPath . length === 0 ) {
106
108
continue
107
109
}
108
110
}
@@ -124,14 +126,14 @@ function findPath(request, paths, isMain, fields, exts) {
124
126
isMJS ( thePath ) ) {
125
127
stat = statSync ( thePath )
126
128
127
- if ( stat ) {
129
+ if ( stat !== null ) {
128
130
rc = Reflect . apply ( isFile , stat , [ ] ) ? 0 : 1
129
131
}
130
132
} else {
131
133
rc = statFast ( thePath )
132
134
}
133
135
134
- let filename
136
+ let filename = ""
135
137
136
138
if ( ! trailingSlash ) {
137
139
// If a file.
@@ -141,7 +143,7 @@ function findPath(request, paths, isMain, fields, exts) {
141
143
: thePath
142
144
}
143
145
144
- if ( ! filename ) {
146
+ if ( filename . length === 0 ) {
145
147
if ( exts === void 0 ) {
146
148
exts = keys ( Module . _extensions )
147
149
}
@@ -152,7 +154,7 @@ function findPath(request, paths, isMain, fields, exts) {
152
154
153
155
// If a directory.
154
156
if ( rc === 1 &&
155
- ! filename ) {
157
+ filename . length === 0 ) {
156
158
if ( exts === void 0 ) {
157
159
exts = keys ( Module . _extensions )
158
160
}
@@ -170,7 +172,7 @@ function findPath(request, paths, isMain, fields, exts) {
170
172
tryExtensions ( resolve ( thePath , "index" ) , exts , isMain )
171
173
}
172
174
173
- if ( filename ) {
175
+ if ( filename . length > 0 ) {
174
176
cache . set ( cacheKey , filename )
175
177
return filename
176
178
}
@@ -212,7 +214,7 @@ function tryFilename(filename, isMain) {
212
214
isMJS ( filename ) ) {
213
215
stat = statSync ( filename )
214
216
215
- if ( stat ) {
217
+ if ( stat !== null ) {
216
218
rc = Reflect . apply ( isFile , stat , [ ] ) ? 0 : 1
217
219
}
218
220
} else {
@@ -228,7 +230,7 @@ function tryFilename(filename, isMain) {
228
230
: resolveSymlinks
229
231
230
232
if ( useRealpath &&
231
- ( ! stat ||
233
+ ( stat === null ||
232
234
stat . nlink > 1 ||
233
235
isSymLink ) ) {
234
236
return realpath ( filename )
@@ -238,10 +240,10 @@ function tryFilename(filename, isMain) {
238
240
}
239
241
240
242
function tryPackage ( dirPath , fields , exts , isMain ) {
241
- const json = readPackage ( dirPath , fields )
243
+ const json = readPackage ( dirPath , fields ) || ""
242
244
243
- if ( ! json ) {
244
- return ""
245
+ if ( json . length === 0 ) {
246
+ return json
245
247
}
246
248
247
249
for ( const field of fields ) {
0 commit comments