INNER CODE UNIT · Python
find_common_prefix
DmitryRyumin/ICCV-2023-25-Papers · code/markdown_to_json_parser.py:184
def find_common_prefix(urls):
if not urls or not all(urls):
return ""
first_parts = urlsplit(urls[0])
common_prefix = f"{first_parts.scheme}://{first_parts.netloc}"
path_prefix = first_parts.path
for url in urls[1:]:
parsed_url = urlsplit(url)
if (
parsed_url.scheme != first_parts.scheme
or parsed_url.netloc != first_parts.netloc
):
common_prefix = f"{parsed_url.scheme}://{parsed_url.netloc}"
break