Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit efdc87b

Browse files
committed
avoid string building in PrefixedPath.basename
1 parent 5f2cb34 commit efdc87b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

services/path.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ def basename(self) -> str:
109109
The base path name (including the prefix). For example, if `full_path`
110110
is `a/b/c/d.txt` and `prefix` is `a/b` then this method would return `a/b/c`.
111111
"""
112-
name = self.relative_path.split("/", 1)[0]
113-
if self.prefix:
114-
return f"{self.prefix}/{name}"
112+
name = self.full_path.rsplit("/", 1)[0]
113+
if name == self.prefix:
114+
return self.full_path
115115
else:
116116
return name
117117

0 commit comments

Comments
 (0)