Skip to content

Commit 5b57a50

Browse files
Properly read user and repo for github portal for github portal
1 parent 80f03c6 commit 5b57a50

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

frictionless/portals/github/plugin.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import TYPE_CHECKING, Any, Optional
3+
from typing import TYPE_CHECKING, Any, Optional, Tuple
44
from urllib.parse import urlparse
55

66
from ...system import Plugin
@@ -29,16 +29,22 @@ def create_adapter(
2929
if not control or isinstance(control, GithubControl):
3030
if parsed.netloc == "github.com":
3131
control = control or GithubControl()
32-
splited_url = parsed.path.split("/")[1:]
33-
if len(splited_url) == 1:
34-
control.user = splited_url[0]
35-
return GithubAdapter(control)
36-
if len(splited_url) == 2:
37-
control.user, control.repo = splited_url
32+
33+
control.user, control.repo = self._extract_user_and_repo(parsed.path)
34+
3835
return GithubAdapter(control)
3936
if source is None and isinstance(control, GithubControl):
4037
return GithubAdapter(control=control)
4138

4239
def select_control_class(self, type: Optional[str] = None):
4340
if type == "github":
4441
return GithubControl
42+
43+
@staticmethod
44+
def _extract_user_and_repo(url_path: str) -> Tuple[Optional[str], Optional[str]]:
45+
splitted_url = url_path.split("/")[1:]
46+
47+
user = splitted_url[0] if len(splitted_url) >= 1 else None
48+
repo = splitted_url[1] if len(splitted_url) >= 2 else None
49+
50+
return (user, repo)

0 commit comments

Comments
 (0)