Skip to content

Commit 5b4cc8c

Browse files
Kasper JungeRalphify
authored andcommitted
refactor: use Path.name instead of rsplit for leaf directory extraction
Path(subpath).name is the idiomatic way to extract the last path component, replacing the less readable rsplit("/", 1)[-1] pattern. Co-authored-by: Ralphify <noreply@ralphify.co>
1 parent 1f1c27e commit 5b4cc8c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/ralphify/_source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def parse_github_source(source: str) -> ParsedSource:
8989
repo_url = f"https://github.com/{owner}/{repo}.git"
9090
subpath = rest.strip("/") if rest else None
9191
subpath = subpath or None # normalize empty string to None
92-
name = subpath.rsplit("/", 1)[-1] if subpath else repo
92+
name = Path(subpath).name if subpath else repo
9393
handle = f"{owner_repo}/{subpath}" if subpath else owner_repo
9494

9595
return ParsedSource(owner_repo=owner_repo, repo_url=repo_url, subpath=subpath, handle=handle, name=name)

0 commit comments

Comments
 (0)