File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 1
1
package main
2
2
3
- import "strings"
3
+ import (
4
+ "fmt"
5
+ "strings"
6
+ )
4
7
5
8
func normalizeFileName (filePath string ) string {
6
9
normalized := strings .Replace (strings .ToLower (filePath ), "_" , "-" , - 1 )
@@ -21,10 +24,13 @@ func handlePypiFileNames(key string) string {
21
24
22
25
// handlePypiDirlist works around the fact that dirlistings are case insensitive so direct search for the path might fail
23
26
func handlePypiListDir (fetcher FileFetcher , path string ) ([]ListDirEntry , error ) {
24
-
25
27
prefix := strings .TrimPrefix (path , "/" ) // remove initial /
26
28
prefix = strings .TrimSuffix (prefix , "/" ) // and last one
27
29
30
+ if len (prefix ) < 1 {
31
+ return nil , fmt .Errorf ("expected a directory to list" )
32
+ }
33
+
28
34
// case-insensitive search, search for X* + x*
29
35
firstLetter := prefix [0 :1 ]
30
36
lowerFiles , err := fetcher .ListDir (strings .ToLower (firstLetter ))
You can’t perform that action at this time.
0 commit comments