This repository was archived by the owner on Jul 31, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed
src/main/java/com/kttdevelopment/simplehttpserver/handler Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -146,10 +146,9 @@ public final File getFile(final String path){
146146 final String fileName = targetFile .getParentFile () == null ? targetFile .getPath () : targetFile .getName ();
147147
148148 // for each file in parent directory, run adapter to find file that matches adapted name
149- for (final File file : Objects .requireNonNullElse (parentFile .listFiles (), new File [0 ])){
150- if (fileName .equals (file . isDirectory () ? file . getName () : adapter .getName (file ))) // use adapter name only if not a directory
149+ for (final File file : Objects .requireNonNullElse (parentFile .listFiles (), new File [0 ]))
150+ if (fileName .equals (adapter .getName (file )))
151151 return file ;
152- }
153152 return null ;
154153 }
155154
@@ -200,7 +199,7 @@ public final byte[] getBytes(final String path){
200199 }else {
201200 try {
202201 final File file = Objects .requireNonNull (getFile (path )); // check if file is allowed
203- return ! file .isDirectory () ? adapter .getBytes (file , Files .readAllBytes (file .toPath ())) : null ; // adapt bytes here
202+ return file .isFile () ? adapter .getBytes (file , Files .readAllBytes (file .toPath ())) : null ; // adapt bytes here
204203 }catch (final NullPointerException | IOException ignored ){
205204 return null ;
206205 }
You can’t perform that action at this time.
0 commit comments