diff --git a/src/main/java/org/editorconfig/core/EditorConfig.java b/src/main/java/org/editorconfig/core/EditorConfig.java index e7d2a73..439127c 100644 --- a/src/main/java/org/editorconfig/core/EditorConfig.java +++ b/src/main/java/org/editorconfig/core/EditorConfig.java @@ -85,6 +85,16 @@ public List getProperties(String filePath) throws EditorConfigException String dir = new File(filePath).getParent(); while (dir != null && !root) { String configPath = dir + "/" + configFilename; + + /** + * allows .../*.editorconfig files + */ + for (File file : new File(dir).listFiles()) { + if (getFileExtension(file).equals(configFilename)) { + configPath = file.getAbsolutePath(); + } + } + if (new File(configPath).exists()) { FileInputStream stream = new FileInputStream(configPath); InputStreamReader reader = new InputStreamReader(stream, "UTF-8"); @@ -115,6 +125,15 @@ public List getProperties(String filePath) throws EditorConfigException return result; } + private String getFileExtension(File file) { + String name = file.getName(); + int lastIndexOf = name.lastIndexOf("."); + if (lastIndexOf == -1) { + return ""; // empty extension + } + return name.substring(lastIndexOf); + } + private void checkAssertions() throws VersionException { if (compareVersions(version, VERSION) > 0) { throw new VersionException("Required version is greater than the current version.");