Skip to content

Commit 0f815ee

Browse files
authored
Merge pull request #667 from NativeScript/pete/require-module-with-js-in-name
Check for module with .js in the name before attempting to resolve file
2 parents 5bba34c + 1816ea6 commit 0f815ee

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

runtime/src/main/java/com/tns/Module.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ private static File resolveFromFileOrDirectory(String baseDir, String path, File
179179
File foundModule = null;
180180

181181
foundModule = loadAsFile(fileOrDirectory);
182+
182183
if(foundModule != null) {
183184
return foundModule;
184185
}
@@ -198,6 +199,8 @@ private static File resolveFromFileOrDirectory(String baseDir, String path, File
198199
//cache resolved directory
199200
if(foundModule != null) {
200201
folderAsModuleCache.put(fileOrDirectory.getCanonicalPath(), foundModule.getCanonicalPath());
202+
203+
return foundModule;
201204
}
202205

203206
return foundModule;
@@ -222,7 +225,8 @@ private static File loadAsFile(File path) {
222225

223226
File foundFile = new File(path.getAbsolutePath() + fallbackExtension);
224227
try {
225-
if(foundFile.getCanonicalFile().exists()) {
228+
File canonicalFile = foundFile.getCanonicalFile();
229+
if (canonicalFile.exists() && canonicalFile.isFile()) {
226230
return foundFile;
227231
}
228232
} catch (IOException e) {

0 commit comments

Comments
 (0)