Fix absolute include patterns in nginx config discovery #39

Merged
wagesj45 merged 1 commit from codex/fix-notimplementederror-in-analysis into main 2025-07-19 03:17:58 -05:00
Showing only changes of commit 2443aecaf6 - Show all commits

fix nginx config discovery for absolute include patterns

Jordan Wages 2025-07-19 03:17:07 -05:00

View file

@ -49,7 +49,15 @@ def discover_configs() -> Set[Path]:
found.add(path)
for pattern in INCLUDE_RE.findall(text):
pattern = os.path.expanduser(pattern.strip())
for included in path.parent.glob(pattern):
if os.path.isabs(pattern):
# ``Path.glob`` does not allow absolute patterns, so we
# anchor at the filesystem root and remove the leading
# separator.
base = Path(os.sep)
glob_iter = base.glob(pattern.lstrip(os.sep))
else:
glob_iter = path.parent.glob(pattern)
for included in glob_iter:
if included.is_file() and included not in found:
queue.append(included)
return found