Skip to content

Commit

Permalink
Make compare_urls() a class method.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjerdonek committed Mar 22, 2019
1 parent a829362 commit 352ac81
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pip/_internal/vcs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,20 +364,22 @@ def get_url_rev_options(self, url):

return url, rev_options

def normalize_url(self, url):
@staticmethod
def normalize_url(url):
# type: (str) -> str
"""
Normalize a URL for comparison by unquoting it and removing any
trailing slash.
"""
return urllib_parse.unquote(url).rstrip('/')

def compare_urls(self, url1, url2):
@classmethod
def compare_urls(cls, url1, url2):
# type: (str, str) -> bool
"""
Compare two repo URLs for identity, ignoring incidental differences.
"""
return (self.normalize_url(url1) == self.normalize_url(url2))
return (cls.normalize_url(url1) == cls.normalize_url(url2))

@classmethod
def fetch_new(cls, dest, url, rev_options):
Expand Down

0 comments on commit 352ac81

Please sign in to comment.