Skip to content

Commit c37d5d9

Browse files
committed
Added logic to toggle partial or exact matches between str pattern and the candidate list
1 parent 9e17e5a commit c37d5d9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/murfey/util/api.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def load_route_manifest(
3434
def find_unique_index(
3535
pattern: str,
3636
candidates: list[str],
37+
partial: bool = True, # Allows partial matches
3738
) -> int:
3839
"""
3940
Finds the index of a unique entry in a list.
@@ -42,7 +43,7 @@ def find_unique_index(
4243
matches = []
4344
index = 0
4445
for i, candidate in enumerate(candidates):
45-
if pattern in candidate:
46+
if (partial and pattern in candidate) or (not partial and pattern == candidate):
4647
counter += 1
4748
matches.append(candidate)
4849
index = i
@@ -93,12 +94,12 @@ def url_path_for(
9394
# Load the routes in the desired router
9495
routers = list(route_manifest.keys())
9596
routes: list[dict[str, Any]] = route_manifest[
96-
routers[find_unique_index(router_name, routers)]
97+
routers[find_unique_index(router_name, routers, partial=True)]
9798
]
9899

99100
# Search router for the function
100101
route_info = routes[
101-
find_unique_index(function_name, [r["function"] for r in routes])
102+
find_unique_index(function_name, [r["function"] for r in routes], partial=False)
102103
]
103104

104105
# Unpack the dictionary

0 commit comments

Comments
 (0)