Skip to content

Commit

Permalink
fix query
Browse files Browse the repository at this point in the history
  • Loading branch information
wistefan committed Oct 15, 2024
1 parent 9d2ad99 commit 04cf8b2
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/main/resources/rego/ngsi-ld/leftOperand.rego
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package ngsild.leftOperand

import rego.v1

import future.keywords.in

# helper method to retrieve the type from the path
type_from_path(path) := tfe if {
type_from_path(path, query) := tfe if {
path_without_query := split(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 = query.type
}

# helper to retrieve the type from the body
Expand All @@ -22,7 +19,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.path, http_part.query)
} else := tfb if {
tfb = type_from_body(http_part.body)
}
Expand Down

0 comments on commit 04cf8b2

Please sign in to comment.