Skip to content

Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.

fix(parser): resolve links and images against the HTML base URL

HelloWorld332626855f51798f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 648be42..5aaf539 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Fixed
+
+- Resolve relative image and link URLs using the first document base href.
+
## [2.5.0] - 2026-10-22
Security and accuracy fixes from a full audit, and Claude Desktop installs again.
diff --git a/scripts/parse_html.py b/scripts/parse_html.py
index 8c411c5..9378add 100755
--- a/scripts/parse_html.py
+++ b/scripts/parse_html.py
@@ -100,6 +100,15 @@ def parse_html(html: str, base_url: Optional[str] = None) -> dict:
Dictionary with extracted SEO data
"""
soup = BeautifulSoup(html, _HTML_PARSER)
+ resource_base_url = base_url
+ base = soup.find("base", href=True)
+ if base:
+ try:
+ candidate = urljoin(base_url or "", base["href"])
+ if urlparse(candidate).scheme.lower() not in {"data", "javascript"}:
+ resource_base_url = candidate
+ except ValueError:
+ pass # An invalid base falls back to the document URL.
result = {
"title": None,
@@ -184,8 +193,8 @@ def parse_html(html: str, base_url: Optional[str] = None) -> dict:
# Images
for img in soup.find_all("img"):
src = img.get("src", "")
- if base_url and src:
- src = urljoin(base_url, src)
+ if resource_base_url and src:
+ src = urljoin(resource_base_url, src)
result["images"].append({
"src": src,
@@ -205,7 +214,7 @@ def parse_html(html: str, base_url: Optional[str] = None) -> dict:
if not href or href.startswith("#") or href.startswith("javascript:"):
continue
- full_url = urljoin(base_url, href)
+ full_url = urljoin(resource_base_url, href)
parsed = urlparse(full_url)
link_data = {
diff --git a/tests/test_document_base_url.py b/tests/test_document_base_url.py
new file mode 100644
index 0000000..dac1fd7
--- /dev/null
+++ b/tests/test_document_base_url.py
@@ -0,0 +1,30 @@
+"""Resolve relative resources against the document's first base href."""
+import sys
+from pathlib import Path
+
+import pytest
+
+sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "scripts"))
+from parse_html import parse_html # noqa: E402
+
+
+ ("head", "prefix", "kind"),
+ [
+ ('<base href="https://cdn.example.net/docs/">', "https://cdn.example.net/docs/", "external"),
+ ('<base href="/docs/">', "https://example.com/docs/", "internal"),
+ ('<base href="//cdn.example.net/docs/">', "https://cdn.example.net/docs/", "external"),
+ ('<base target="_blank"><base href="/docs/">', "https://example.com/docs/", "internal"),
+ ('<base href="/first/"><base href="/second/">', "https://example.com/first/", "internal"),
+ ('<base href="">', "https://example.com/blog/", "internal"),
+ ('<base href="javascript:alert(1)"><base href="/ignored/">', "https://example.com/blog/", "internal"),
+ ('<base href="http://[invalid">', "https://example.com/blog/", "internal"),
+ ("", "https://example.com/blog/", "internal"),
+ ],
+)
+def test_resource_urls_follow_document_base(head, prefix, kind):
+ html = f'<html><head>{head}</head><body><a href="guide">Guide</a><img src="cover.png"></body></html>'
+ result = parse_html(html, "https://example.com/blog/post")
+ assert result["links"][kind][0]["href"] == prefix + "guide"
+ assert result["links"]["internal" if kind == "external" else "external"] == []
+ assert result["images"][0]["src"] == prefix + "cover.png"