Fix for sites that have a base tag

This commit is contained in:
Wasi Master
2026-07-12 21:47:11 +06:00
parent 06746d6017
commit f789fdcfd4
+5 -1
View File
@@ -618,7 +618,11 @@ def process_html_document(html_content, original_url):
base_url = urljoin(base_url, parsed_url.path.rsplit("/", 1)[0] + "/") base_url = urljoin(base_url, parsed_url.path.rsplit("/", 1)[0] + "/")
base_tag = soup.find("base") base_tag = soup.find("base")
if not base_tag: if base_tag:
# Always overwrite — sites may have <base href="/"> which would resolve
# root-relative asset paths to the 13ft server instead of the original domain.
base_tag["href"] = base_url
else:
new_base_tag = soup.new_tag("base", href=base_url) new_base_tag = soup.new_tag("base", href=base_url)
if soup.head: if soup.head:
soup.head.insert(0, new_base_tag) soup.head.insert(0, new_base_tag)