refactor: consolidate exact post dispatch
This commit is contained in:
@@ -37,16 +37,15 @@ def page_inventory(html: str) -> list[dict[str, str]]:
|
||||
|
||||
|
||||
def api_inventory(server: str) -> dict[str, list[str]]:
|
||||
exact = sorted(set(re.findall(r'parsed\.path\s*==\s*"(/api/[^"]+)"', server)))
|
||||
routes = json.loads(source("config/api.config.json"))["routes"]
|
||||
exact = sorted(
|
||||
{item["path"] for item in routes if item["match"] == "exact"}
|
||||
)
|
||||
prefixes = sorted(
|
||||
set(re.findall(r'parsed\.path\.startswith\(\s*"(/api/[^"]+)"', server))
|
||||
)
|
||||
patterns = sorted(
|
||||
set(
|
||||
item
|
||||
for item in re.findall(r'r?["\']([^"\']*?/api/[^"\']+)["\']', server)
|
||||
if "\\d" in item or ".+" in item or "(?P" in item
|
||||
)
|
||||
{item["path"] for item in routes if item["match"] == "regex"}
|
||||
)
|
||||
return {"exact": exact, "prefixes": prefixes, "patterns": patterns}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user