Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent pathname definition. #106

Open
oschneidewind opened this issue Jun 16, 2024 · 2 comments
Open

Inconsistent pathname definition. #106

oschneidewind opened this issue Jun 16, 2024 · 2 comments

Comments

@oschneidewind
Copy link

Description

When evaluating this package, I noticed that the pathname of an HTTPS address is output with a leading backslash, but for an SSH address without one, which means for my application that I have to check which protocol is used in order to edit the pathname if necessary.

My expectation would be that the pathname always returns the same regardless of the protocol (ideally without a leading backslash)

Steps to reproduce

The following code demonstrates the issue, the assertion is triggered, which proves the inconsistent API.

html_parse = giturlparse.parse("https://github.com/nephila/giturlparse.git")
ssh_parse = giturlparse.parse(html_parse.url2ssh)
assert ssh_parse.pathname == html_parse.pathname

Versions

Python 3.12.3

Expected behaviour

The pathname is always the same regardless of the protocol and the assertion is not triggered.

Actual behaviour

It does matter which URL is parsed, the assertion is triggered, which requires an additional processing step.

Additional information

@mathrick
Copy link

@oschneidewind: there's a wrinkle here, namely that ssh distinguishes between user@hostname:foo, and user@hostname:/foo. The former means "foo, relative to user's default directory (usually their home dir)", whereas the latter means "absolute path /foo, (ie. relative to filesystem root)". So whilst it'd be very unusual to see, say, github give you an absolute path in the SSH URL, it doesn't mean such a path can't exist in a URL, and it wouldn't be the same thing.

@oschneidewind
Copy link
Author

@mathrick I agree with you, the thing with the ssh url is unlikely but not impossible, but it bothers me that it is inconsistent between the protocols, this can also be solved by leaving out the slash in http parser.
If I use the parser, I want a consistent result. Otherwise I have to parse it myself, and then the package has less value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants