isSingleResourcePath returns true when the path's only path parameter is at the trailing position (e.g. /users/{userId}, /accounts/{aid}). We deliberately reject paths like /users/{userId}/profile because their semantic mapping to a join key is ambiguous without explicit user input.
(path string)
| 373 | // We deliberately reject paths like /users/{userId}/profile because their |
| 374 | // semantic mapping to a join key is ambiguous without explicit user input. |
| 375 | func isSingleResourcePath(path string) bool { |
| 376 | segs := strings.Split(strings.Trim(path, "/"), "/") |
| 377 | if len(segs) == 0 { |
| 378 | return false |
| 379 | } |
| 380 | last := segs[len(segs)-1] |
| 381 | return strings.HasPrefix(last, "{") && strings.HasSuffix(last, "}") |
| 382 | } |
| 383 | |
| 384 | // splitPath turns "data.items" into ["data", "items"]. Empty input |
| 385 | // returns nil so downstream code can treat "no result path" as a single |