mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-17 14:19:54 +05:00
Updated cgr-loader to accept URLs as path to data
This commit is contained in:
committed by
Dan Christian Bogos
parent
d4fc68c86b
commit
57cfcbf5fc
@@ -942,3 +942,9 @@ type LoadIDsWithArgDispatcher struct {
|
||||
TenantArg
|
||||
*ArgDispatcher
|
||||
}
|
||||
|
||||
// IsURL returns if the path is an URL
|
||||
func IsURL(path string) bool {
|
||||
return strings.HasPrefix(path, "https://") ||
|
||||
strings.HasPrefix(path, "http://")
|
||||
}
|
||||
|
||||
@@ -1349,3 +1349,16 @@ func TestGetPathIndex(t *testing.T) {
|
||||
t.Errorf("Expecting: nil, received: %+v", *index)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsURL(t *testing.T) {
|
||||
urls := map[string]bool{
|
||||
"/etc/usr/": false,
|
||||
"https://github.com/cgrates/cgrates/": true,
|
||||
"http://github.com/cgrates/cgrates/i": true,
|
||||
}
|
||||
for url, expected := range urls {
|
||||
if rply := IsURL(url); rply != expected {
|
||||
t.Errorf("For: %q ,expected %v received: %v", url, expected, rply)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user