From 39682629f95557657e2a5db01028d60dd02e7ca2 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Fri, 19 May 2023 14:26:17 -0700 Subject: [PATCH] [ci-force] d2oracle.GetID --- d2oracle/get.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/d2oracle/get.go b/d2oracle/get.go index c20f1f892..f45661e68 100644 --- a/d2oracle/get.go +++ b/d2oracle/get.go @@ -84,3 +84,18 @@ func IsLabelKeyID(key, label string) bool { return mk.Key.Path[len(mk.Key.Path)-1].Unbox().ScalarString() == label } + +func GetID(key string) string { + mk, err := d2parser.ParseMapKey(key) + if err != nil { + return "" + } + if len(mk.Edges) > 0 { + return "" + } + if mk.Key == nil { + return "" + } + + return mk.Key.Path[len(mk.Key.Path)-1].Unbox().ScalarString() +}