Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Release type: patch

Support `SITEURL` values that contain slugs after the domain
5 changes: 5 additions & 0 deletions pelican/plugins/seo/seo_enhancer/html_enhancer/open_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def __init__(

def _create_absolute_fileurl(self):
"""Join site URL and file path."""
if not self.siteurl.endswith("/"):
self.siteurl += "/"

if self.fileurl.startswith("/"):
self.fileurl = self.fileurl[1:]

file_url = parse.urljoin(self.siteurl, self.fileurl)
return file_url
Expand Down
22 changes: 22 additions & 0 deletions pelican/plugins/seo/tests/test_open_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,28 @@ def test_create_absolute_fileurl(self, fake_article):

assert fileurl == "https://www.fakesite.com/fake-title.html"

@pytest.mark.parametrize(
"site_url", ["https://fake.github.io/blog", "https://fake.github.io/blog/"]
)
@pytest.mark.parametrize("file_url", ["fake-title.html", "/fake-title.html"])
def test_create_absolute_fileurl_with_site_url_with_path(self, site_url, file_url):
"""
Test if create_absolute_fileurl() joins a site URL with or without a trailing
slash and a file URL with or without a leading slash properly.
"""
og = OpenGraph(
siteurl=site_url,
fileurl=file_url,
file_type=None,
title=None,
description=None,
image=None,
locale=None,
)
fileurl = og._create_absolute_fileurl()

assert fileurl == "https://fake.github.io/blog/fake-title.html"

@pytest.mark.parametrize(
"locale,expected_result",
[
Expand Down