forked from Plemya-x/ALR
		
	chore: refactor code
- remove legacy code - refactor search and add tests
This commit is contained in:
		| @@ -22,10 +22,11 @@ package handlers | ||||
| import ( | ||||
| 	"context" | ||||
| 	"io" | ||||
| 	"io/fs" | ||||
| 	"os" | ||||
| ) | ||||
|  | ||||
| func NopReadDir(context.Context, string) ([]os.FileInfo, error) { | ||||
| func NopReadDir(context.Context, string) ([]fs.DirEntry, error) { | ||||
| 	return nil, os.ErrNotExist | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -31,12 +31,12 @@ import ( | ||||
| 	"mvdan.cc/sh/v3/interp" | ||||
| ) | ||||
|  | ||||
| func RestrictedReadDir(allowedPrefixes ...string) interp.ReadDirHandlerFunc { | ||||
| 	return func(ctx context.Context, s string) ([]fs.FileInfo, error) { | ||||
| func RestrictedReadDir(allowedPrefixes ...string) interp.ReadDirHandlerFunc2 { | ||||
| 	return func(ctx context.Context, s string) ([]fs.DirEntry, error) { | ||||
| 		path := filepath.Clean(s) | ||||
| 		for _, allowedPrefix := range allowedPrefixes { | ||||
| 			if strings.HasPrefix(path, allowedPrefix) { | ||||
| 				return interp.DefaultReadDirHandler()(ctx, s) | ||||
| 				return interp.DefaultReadDirHandler2()(ctx, s) | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user