Skip to content

Commit 2d873b5

Browse files
authored
Merge pull request #1082 from readthedocs/davidfischer/bugfix-niche-urls-form
Fix a bug with niche URL handling
2 parents 2ee3f6d + 1cef2c0 commit 2d873b5

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

adserver/analyzer/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def normalize_url(url):
3030
Currently, this means:
3131
- Removing ignored query paramters
3232
"""
33+
url = url.strip()
3334
parts = urlparse.urlparse(url)
3435

3536
query_params = urlparse.parse_qs(parts.query, keep_blank_values=True)

adserver/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ def clean_niche_urls(self):
346346
raise forms.ValidationError(
347347
_("'%(url)s' is an invalid URL."), params={"url": url}
348348
)
349-
return data
349+
return "\n".join(niche_urls)
350350

351351
def save(self, commit=True):
352352
if not self.instance.targeting_parameters:

adserver/tests/test_advertiser_dashboard.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ def test_flight_update_view(self):
408408
"include_keywords": "python, django",
409409
"niche_distance": 0.5,
410410
"niche_urls": "\n".join([
411-
"https://example.com/niche1/",
411+
# Make sure comments are stripped properly
412+
"https://example.com/niche1/ ",
412413
"https://example.com/niche2/",
413414
]),
414415
}

0 commit comments

Comments
 (0)