Skip to content

Commit 7b75c77

Browse files
fix: guard extract remap against paths outside root
1 parent 7cff543 commit 7b75c77

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

graphify/extract.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9088,7 +9088,11 @@ def extract(
90889088
id_remap: dict[str, str] = {}
90899089
for path in paths:
90909090
canonical = _file_node_id(path)
9091-
old_ids = {_make_id(str(path)), _make_id(str(path.relative_to(root)))}
9091+
try:
9092+
rel = path.relative_to(root)
9093+
except ValueError:
9094+
continue
9095+
old_ids = {_make_id(str(path)), _make_id(str(rel))}
90929096
for old_id in old_ids:
90939097
if old_id != canonical:
90949098
id_remap[old_id] = canonical

tests/test_import_extension_resolution.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
from pathlib import Path
1212

1313
from graphify.extract import (
14-
extract_js, extract_python,
15-
_make_id, _file_node_id, _import_targets,
14+
extract_js, extract_python, extract_svelte,
15+
_make_id, _file_node_id,
16+
_resolve_js_module_path,
1617
)
1718

1819

0 commit comments

Comments
 (0)