Skip to content

Commit 2b720ee

Browse files
committed
Merge branch 'main' of github.com:readthedocs/readthedocs.org into diataxis/main
2 parents e2ed818 + 7ae0e12 commit 2b720ee

File tree

5 files changed

+30
-14
lines changed

5 files changed

+30
-14
lines changed

docs/user/guides/jupyter.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,15 @@ For example, this is how a simple notebook looks like in MyST Markdown format:
175175
176176
---
177177
jupytext:
178-
text_representation:
179-
extension: .md
180-
format_name: myst
181-
format_version: 0.13
182-
jupytext_version: 1.10.3
178+
text_representation:
179+
extension: .md
180+
format_name: myst
181+
format_version: 0.13
182+
jupytext_version: 1.10.3
183183
kernelspec:
184-
display_name: Python 3
185-
language: python
186-
name: python3
184+
display_name: Python 3
185+
language: python
186+
name: python3
187187
---
188188
189189
# Plain-text notebook formats

readthedocs/analytics/proxied_api.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from readthedocs.analytics.models import PageView
1010
from readthedocs.api.v2.permissions import IsAuthorizedToViewVersion
11-
from readthedocs.core.unresolver import unresolve
11+
from readthedocs.core.unresolver import UnresolverError, unresolve
1212
from readthedocs.core.utils.extend import SettingsOverrideObject
1313
from readthedocs.projects.models import Project
1414

@@ -59,8 +59,14 @@ def get(self, request, *args, **kwargs):
5959
# pylint: disable=no-self-use
6060
def increase_page_view_count(self, project, version, absolute_uri):
6161
"""Increase the page view count for the given project."""
62-
unresolved = unresolve(absolute_uri)
63-
if not unresolved or not unresolved.filename:
62+
try:
63+
unresolved = unresolve(absolute_uri)
64+
except UnresolverError:
65+
# If we were unable to resolve the URL, it
66+
# isn't pointing to a valid RTD project.
67+
return
68+
69+
if not unresolved.filename:
6470
return
6571

6672
path = unresolved.filename

readthedocs/analytics/tests.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ def setUp(self):
118118
self.tomorrow = timezone.now() + timezone.timedelta(days=1)
119119
self.yesterday = timezone.now() - timezone.timedelta(days=1)
120120

121+
def test_invalid_uri(self):
122+
assert PageView.objects.all().count() == 0
123+
url = (
124+
reverse("analytics_api")
125+
+ f"?project={self.project.slug}&version={self.version.slug}"
126+
f"&absolute_uri=https://docs.example.com"
127+
)
128+
self.client.get(url, HTTP_HOST=self.host)
129+
assert PageView.objects.all().count() == 0
130+
121131
def test_increase_page_view_count(self):
122132
assert (
123133
PageView.objects.all().count() == 0

requirements/docs.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ sphinx-tabs==3.3.1
1010
sphinx-intl==2.0.1
1111
sphinx-design==0.2.0
1212
sphinx-multiproject==1.0.0rc1
13-
readthedocs-sphinx-search==0.1.2
13+
readthedocs-sphinx-search
1414

1515
# Test out hoverxref
1616
git+https://github.com/readthedocs/sphinx-hoverxref

requirements/docs.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ pygments==2.14.0
5757
# sphinx-tabs
5858
pytz==2022.7.1
5959
# via babel
60-
pyyaml==5.4.1
60+
pyyaml==6.0
6161
# via myst-parser
62-
readthedocs-sphinx-search==0.1.2
62+
readthedocs-sphinx-search==0.2.0
6363
# via -r requirements/docs.in
6464
requests==2.28.2
6565
# via sphinx

0 commit comments

Comments
 (0)