Skip to content

Commit

Permalink
Add trailing slash to URL path, not the entire URL
Browse files Browse the repository at this point in the history
fixes #1348

This is built on some hefty changes made for 2.7, and (for the moment)
isn't wanted by anyone but me (re #928), but can find its way as far
back as pulp_rpm 2.4 if needed.
  • Loading branch information
Sean Myers committed Nov 3, 2015
1 parent a3871ae commit 63863b4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 8 additions & 3 deletions plugins/pulp_rpm/plugins/importers/yum/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import traceback
from gettext import gettext as _
from cStringIO import StringIO

from urlparse import urlparse, urlunparse

from nectar.request import DownloadRequest

Expand Down Expand Up @@ -90,8 +90,13 @@ def sync_feed(self):
if repo_url:
repo_url_slash = repo_url
self.tmp_dir = tempfile.mkdtemp(dir=self.working_dir)
if not repo_url.endswith('/'):
repo_url_slash = repo_url + '/'
parsed = urlparse(repo_url)
path = parsed.path
if not path.endswith('/'):
path += '/'
repo_url_slash = urlunparse(
(parsed.scheme, parsed.netloc, path, parsed.params, parsed.query, parsed.fragment)
)
try:
self.check_metadata(repo_url_slash)
return [repo_url_slash]
Expand Down
12 changes: 12 additions & 0 deletions plugins/test/unit/plugins/importers/yum/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,18 @@ def test_without_trailing_slash(self, mock_check_metadata):

self.assertEqual(ret, [self.url])

@mock.patch('pulp_rpm.plugins.importers.yum.sync.RepoSync.check_metadata',
spec_set=RepoSync.check_metadata)
def test_query_without_trailing_slash(self, mock_check_metadata):
# it should add back the trailing slash if not present without changing the query string
query = '?foo=bar'
self.config.override_config[importer_constants.KEY_FEED] = self.url.rstrip('/') + query

ret = self.reposync.sync_feed
expected = [self.url + query]

self.assertEqual(ret, expected)

def test_repo_url_is_none(self):

self.config.override_config[importer_constants.KEY_FEED] = None
Expand Down

0 comments on commit 63863b4

Please sign in to comment.