From f1935a119b90f92ea5ac726b08479ba548ffe328 Mon Sep 17 00:00:00 2001 From: SRHTNIN Date: Fri, 9 Oct 2026 10:59:48 +0200 Subject: [PATCH] Flow: added patterns kept their input when RootDir ends in / --- Sortd.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sortd.py b/Sortd.py index b50d2fe..1e2dbfb 100644 --- a/Sortd.py +++ b/Sortd.py @@ -253,13 +253,19 @@ class Setup: return None if not Root or Root == "Unset" else str(Root) def Shorthand(self, PathText: str) -> str: - """How a path is written into GlobalConf: %RootDir%/... when under RootDir.""" + """How a path is written into GlobalConf: %RootDir%/... when under RootDir. + Only when it parses back to the very same path: SaraSortd compares + ValidInputDirs as text, so RootDir = "/home/sarah/" must give + %RootDir%Downloads, not %RootDir%/Downloads (/home/sarah//Downloads).""" Root = self.RootDir() Call = self.Vars.get("VarCall", "%%") if Root and len(Call) >= 2: Root = Root.rstrip("/") if PathText == Root or PathText.startswith(Root + "/"): - return f"{Call[0]}RootDir{Call[1]}{PathText[len(Root):]}" + Lookup = f"{Call[0]}RootDir{Call[1]}" + for Short in (Lookup + PathText[len(Root):], Lookup + PathText[len(Root) + 1:]): + if self.ParsePath(Short) == PathText: + return Short return PathText def ConfFolder(self, PathText: str) -> Path: