Skip to content

Commit

Permalink
Merge 8e81f54 into 9d2ad99
Browse files Browse the repository at this point in the history
  • Loading branch information
wistefan authored Oct 15, 2024
2 parents 9d2ad99 + 8e81f54 commit e65a8d4
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/main/resources/rego/ngsi-ld/leftOperand.rego
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ package ngsild.leftOperand

import rego.v1


# helper method to retrieve the type from the path
type_from_path(path) := tfe if {
path_without_query := split(path, "?")[0]
type_from_path(http_part) := tfe if {
path_without_query := split(http_part.path, "?")[0]
path_elements := split(path_without_query, "/")
id_elements := split(path_elements[count(path_elements) - 1], ":")
tfe = id_elements[2]
} else := tfq if {
query := split(path, "?")[1]
query_parts := split(query, "&")
type_query := [query_part | some query_part in query_parts; contains(query_part, "type=")]
tfq = split(type_query[0], "=")[1]
tfq = http_part.query.type
}

# helper to retrieve the type from the body
Expand All @@ -22,7 +18,7 @@ type_from_body(body) := body.type
## ngsi-ld:entityType
# retrieves the type from an entity, either from the request path or from the body
entity_type(http_part) := tfp if {
tfp = type_from_path(http_part.path)
tfp = type_from_path(http_part)
} else := tfb if {
tfb = type_from_body(http_part.body)
}
Expand Down

0 comments on commit e65a8d4

Please sign in to comment.