nginx-ui/internal/helper/directory_test.go
2024-07-25 18:19:42 +08:00

12 lines
374 B
Go

package helper
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestIsUnderDirectory(t *testing.T) {
assert.Equal(t, true, IsUnderDirectory("/etc/nginx/nginx.conf", "/etc/nginx"))
assert.Equal(t, false, IsUnderDirectory("../../root/nginx.conf", "/etc/nginx"))
assert.Equal(t, false, IsUnderDirectory("/etc/nginx/../../root/nginx.conf", "/etc/nginx"))
}