@@ -38,41 +38,29 @@ def parse_url(url: str) -> dict[str, Any]:
3838 "commit" : None ,
3939 "subpath" : "/" ,
4040 "local_path" : f"{ TMP_BASE_PATH } /{ _id } /{ slug } " ,
41- # Keep original URL format but with decoded components
4241 "url" : f"https://{ domain } /{ user_name } /{ repo_name } " ,
4342 "slug" : slug ,
4443 "id" : _id ,
4544 }
4645
46+ # If this is an issues page, return early without processing subpath
47+ if len (path_parts ) > 2 and (path_parts [2 ] == "issues" or path_parts [2 ] == "pull" ):
48+ return parsed
49+
4750 if len (path_parts ) < 4 :
4851 return parsed
4952
5053 parsed ["type" ] = path_parts [2 ] # Usually 'tree' or 'blob'
5154 commit = path_parts [3 ]
5255
53- # Find the commit hash or reconstruct the branch name
54- remaining_parts = path_parts [3 :]
55-
5656 if _is_valid_git_commit_hash (commit ):
5757 parsed ["commit" ] = commit
58- if len (remaining_parts ) > 1 :
59- parsed ["subpath" ] += "/" .join (remaining_parts [1 :])
60- return parsed
61-
62- # Handle branch names with slashes and special characters
63-
64- # Find the index of the first type indicator ("tree" or "blob"), if any
65- type_indicator_index = next ((i for i , part in enumerate (remaining_parts ) if part in ("tree" , "blob" )), None )
66-
67- if type_indicator_index is None :
68- # No type indicator found; assume the entire input is the branch name
69- parsed ["branch" ] = "/" .join (remaining_parts )
70- return parsed
71-
72- # Found a type indicator; update branch and subpath
73- parsed ["branch" ] = "/" .join (remaining_parts [:type_indicator_index ])
74- if len (remaining_parts ) > type_indicator_index + 2 :
75- parsed ["subpath" ] += "/" .join (remaining_parts [type_indicator_index + 2 :])
58+ if len (path_parts ) > 4 :
59+ parsed ["subpath" ] += "/" .join (path_parts [4 :])
60+ else :
61+ parsed ["branch" ] = commit
62+ if len (path_parts ) > 4 :
63+ parsed ["subpath" ] += "/" .join (path_parts [4 :])
7664
7765 return parsed
7866
0 commit comments