diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index c3a48a0..925d7e8 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -65,7 +65,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11-dev', 'pypy3.8'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', 'pypy3.8'] sphinx-version: ['>=4,<5', '>=5,<6', '>=6a0,<7'] os: [windows-latest, macos-latest, ubuntu-latest] exclude: diff --git a/sphinxext/opengraph/__init__.py b/sphinxext/opengraph/__init__.py index ab8b8f9..a4bc48d 100644 --- a/sphinxext/opengraph/__init__.py +++ b/sphinxext/opengraph/__init__.py @@ -91,7 +91,13 @@ def get_tags( # url tag # Get the URL of the specific page if context["builder"] == "dirhtml": - page_url = urljoin(config["ogp_site_url"], context["pagename"] + "/") + if context["pagename"] == "index": + page_url = config["ogp_site_url"] + elif context["pagename"].endswith("/index"): + relative = context["pagename"].rsplit("/", 1)[0] + page_url = urljoin(config["ogp_site_url"], relative + "/") + else: + page_url = urljoin(config["ogp_site_url"], context["pagename"] + "/") else: page_url = urljoin( config["ogp_site_url"], context["pagename"] + context["file_suffix"] diff --git a/tests/test_options.py b/tests/test_options.py index cc0db17..b814ca7 100644 --- a/tests/test_options.py +++ b/tests/test_options.py @@ -68,7 +68,7 @@ def test_site_url(og_meta_tags): @pytest.mark.sphinx("dirhtml", testroot="simple") def test_dirhtml_url(og_meta_tags): - assert get_tag_content(og_meta_tags, "url") == "http://example.org/en/latest/index/" + assert get_tag_content(og_meta_tags, "url") == "http://example.org/en/latest/" @pytest.mark.sphinx("html", testroot="image")