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 44import io
55import json
66import pathlib
7+ import re
78import sys
89import zipfile
910from urllib .parse import urlparse
@@ -63,13 +64,10 @@ def extract_github_host(api_url: str) -> str:
6364 scheme = parsed_url .scheme
6465 netloc = parsed_url .netloc # This includes the domain and potentially the port
6566
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 ):
7169 # Remove 'api.' prefix but keep the port
72- host_domain = netloc .replace ("api." , "" , 1 )
70+ host_domain = netloc .removeprefix ("api." )
7371 # General case for GitHub Enterprise (netloc is already the host:port)
7472 else :
7573 host_domain = netloc
You can’t perform that action at this time.
0 commit comments