nephila / giturlparse

Parse & rewrite git urls (supports GitHub, Bitbucket, Assembla ...)
https://pypi.python.org/pypi/giturlparse
Apache License 2.0
31 stars 21 forks source link

cannot parse github url #43

Closed nasifimtiazohi closed 1 year ago

nasifimtiazohi commented 2 years ago

fails to parse 'https://github.com/rubygems/rubygems/'. The issue arises from having a / character at the end.

>>> from giturlparse import parse
>>> s = 'https://github.com/rubygems/rubygems/'
>>> p = parse(s)
>>> p.host
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/nasifimtiaz/Library/Caches/pypoetry/virtualenvs/package-locator-2SDQOXag-py3.9/lib/python3.9/site-packages/giturlparse/result.py", line 43, in host
    return self.domain
AttributeError: 'GitUrlParsed' object has no attribute 'domain'
>>> p.owner
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'GitUrlParsed' object has no attribute 'owner'
alingse commented 2 years ago

+1 see this should strip the last / @yakky

if you like, I can make an pull request for this.

davidjray commented 2 years ago

Seeing a similar error AttributeError: 'GitUrlParsed' object has no attribute '_platform_obj'

Removing the trailing slash resolved the issue for me.

yakky commented 1 year ago

Thanks @davidjray @alingse @nasifimtiazohi for reporting this. It has been fixed by an unrelated PR, but I added this case in #53 to guard against regressions