Skip to content
Open
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
11 changes: 10 additions & 1 deletion giturlparse/platforms/github.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import re

from .base import BasePlatform


Expand Down Expand Up @@ -33,7 +35,14 @@ class GitHubPlatform(BasePlatform):
def clean_data(data):
data = BasePlatform.clean_data(data)
if data["path_raw"].startswith("/blob/"):
data["path"] = data["path_raw"].replace("/blob/", "")
path = data["path_raw"].replace("/blob/", "")
branch_regex = re.compile(r"[^/]+")
match = branch_regex.match(path)
branch = match and match[0]
data["branch"] = branch
if branch:
path = path.replace(branch + "/", "")
data["path"] = path
if data["path_raw"].startswith("/tree/"):
data["branch"] = data["path_raw"].replace("/tree/", "")
return data