Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions memsync/harvest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def cwd_to_project_key(cwd: Path) -> str:
# Drive letter colon becomes a dash; backslashes become dashes
# e.g. C:\Users\Ian\foo → C--Users-Ian-foo
raw = str(cwd.resolve())
return raw.replace(":", "-").replace("\\", "-")
return str(cwd.resolve()).replace("/", "-")
return raw.replace(":", "-").replace("\\", "-").replace(" ", "-")
return str(cwd.resolve()).replace("/", "-").replace(" ", "-")


def find_project_dir(
Expand Down
14 changes: 14 additions & 0 deletions tests/test_harvest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ def test_nested_path(self):
p = Path("/Users/ian/Documents/GitHub/memsync")
assert cwd_to_project_key(p) == "-Users-ian-Documents-GitHub-memsync"

def test_spaces_in_path_unix(self):
if platform.system() == "Windows":
pytest.skip("Unix path test")
p = Path("/Users/ian/Documents/Untitled Gods Book")
assert cwd_to_project_key(p) == "-Users-ian-Documents-Untitled-Gods-Book"

def test_spaces_in_path_windows(self, monkeypatch):
if platform.system() != "Windows":
pytest.skip("Windows path test")
p = Path(r"C:\Users\ianfe\OneDrive\Documents\Untitled Gods Book")
key = cwd_to_project_key(p)
assert "Untitled-Gods-Book" in key
assert " " not in key


# ---------------------------------------------------------------------------
# find_project_dir
Expand Down
Loading