2022-03-17 12:19:23 -05:00
|
|
|
package store
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
|
|
"github.com/grafana/grafana/pkg/web"
|
|
|
|
)
|
|
|
|
|
|
|
|
func splitFirstSegment(path string) (string, string) {
|
|
|
|
idx := strings.Index(path, "/")
|
|
|
|
if idx == 0 {
|
|
|
|
path = path[1:]
|
|
|
|
idx = strings.Index(path, "/")
|
|
|
|
}
|
|
|
|
|
|
|
|
if idx > 0 {
|
|
|
|
return path[:idx], path[idx+1:]
|
|
|
|
}
|
|
|
|
return path, ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func getPathAndScope(c *models.ReqContext) (string, string) {
|
|
|
|
params := web.Params(c.Req)
|
|
|
|
path := params["*"]
|
|
|
|
if path == "" {
|
|
|
|
return "", ""
|
|
|
|
}
|
2022-07-07 06:32:18 -05:00
|
|
|
return splitFirstSegment(path)
|
2022-03-17 12:19:23 -05:00
|
|
|
}
|
2022-07-17 13:41:54 -05:00
|
|
|
|
|
|
|
func getFirstSegment(path string) string {
|
|
|
|
firstSegment, _ := splitFirstSegment(path)
|
|
|
|
return firstSegment
|
|
|
|
}
|