File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 4
4
import io
5
5
import json
6
6
import pathlib
7
+ import re
7
8
import sys
8
9
import zipfile
9
10
from urllib .parse import urlparse
@@ -63,13 +64,10 @@ def extract_github_host(api_url: str) -> str:
63
64
scheme = parsed_url .scheme
64
65
netloc = parsed_url .netloc # This includes the domain and potentially the port
65
66
66
- # Special case for GitHub.com API
67
- if netloc == "api.github.com" :
68
- host_domain = "github.com"
69
- # Special case for GitHub.com with port (less common but good practice)
70
- elif netloc .startswith ("api.github.com:" ):
67
+ # Special case for GitHub.com API (including possible port)
68
+ if re .match (r"api\.github\.com(:|$)" , netloc ):
71
69
# Remove 'api.' prefix but keep the port
72
- host_domain = netloc .replace ("api." , "" , 1 )
70
+ host_domain = netloc .removeprefix ("api." )
73
71
# General case for GitHub Enterprise (netloc is already the host:port)
74
72
else :
75
73
host_domain = netloc
You can’t perform that action at this time.
0 commit comments