mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
ftpd: add basic wildcard support
this is the minimal implementation to allow mget and similar commands with wildcards. We only support wildcard for the last path level, for example: - mget *.xml is supported - mget dir/*.xml is supported - mget */*.xml is not supported Removed . and .. from FTP directory listing Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -1002,3 +1002,28 @@ func TestPassiveIPResolver(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, b.ForcePassiveIP, passiveIP)
|
||||
}
|
||||
|
||||
func TestRelativePath(t *testing.T) {
|
||||
rel := getPathRelativeTo("/testpath", "/testpath")
|
||||
assert.Empty(t, rel)
|
||||
rel = getPathRelativeTo("/", "/")
|
||||
assert.Empty(t, rel)
|
||||
rel = getPathRelativeTo("/", "/dir/sub")
|
||||
assert.Equal(t, "dir/sub", rel)
|
||||
rel = getPathRelativeTo("./", "/dir/sub")
|
||||
assert.Equal(t, "/dir/sub", rel)
|
||||
rel = getPathRelativeTo("/sub", "/dir/sub")
|
||||
assert.Equal(t, "../dir/sub", rel)
|
||||
rel = getPathRelativeTo("/dir", "/dir/sub")
|
||||
assert.Equal(t, "sub", rel)
|
||||
rel = getPathRelativeTo("/dir/sub", "/dir")
|
||||
assert.Equal(t, "../", rel)
|
||||
rel = getPathRelativeTo("dir", "/dir1")
|
||||
assert.Equal(t, "/dir1", rel)
|
||||
rel = getPathRelativeTo("", "/dir2")
|
||||
assert.Equal(t, "dir2", rel)
|
||||
rel = getPathRelativeTo(".", "/dir2")
|
||||
assert.Equal(t, "/dir2", rel)
|
||||
rel = getPathRelativeTo("/dir3", "dir3")
|
||||
assert.Equal(t, "dir3", rel)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user