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

Cannot parse ssh://git@bitbucket:7999/MY_ORG/my_repo.git since v12 #153

Open
niryarden opened this issue Oct 3, 2022 · 4 comments · Fixed by Rookout/parse-path#1
Open

Comments

@niryarden
Copy link

The ssh git url from my BitBucket (On-Prem) server isn't parsed properly by the module anymore, since version 12.
I'm not sure what specifically makes it different from other URLs, but it used to work until I tried to upgrade the module, and the URL is copied and pasted from bitbucket, didn't add or remove anything from it.

As you can see, many of the returned attributes are broken:
port, resource, sort, owner, organization, full_name

The URL:

ssh://git@bitbucket:7999/MY_ORG/my_repo.git

git-url-parse version 11.6.0 response:

{
    "protocols": [
        "ssh"
    ],
    "protocol": "ssh",
    "port": 7999,
    "resource": "bitbucket",
    "user": "git",
    "pathname": "/MY_ORG/my_repo.git",
    "hash": "",
    "search": "",
    "href": "ssh://git@bitbucket:7999/MY_ORG/my_repo.git",
    "query": {},
    "token": "",
    "source": "bitbucket",
    "git_suffix": true,
    "name": "my_repo",
    "owner": "MY_ORG",
    "ref": "",
    "filepathtype": "",
    "filepath": "",
    "organization": "MY_ORG",
    "full_name": "MY_ORG/my_repo"
}

git-url-parse version 13.1.0 response:

{
    "protocols": [
        "ssh"
    ],
    "protocol": "ssh",
    "port": "",
    "resource": "",
    "host": "",
    "user": "",
    "password": "",
    "pathname": "//git@bitbucket:7999/MY_ORG/my_repo.git",
    "hash": "",
    "search": "",
    "href": "ssh://git@bitbucket:7999/MY_ORG/my_repo.git",
    "query": {},
    "parse_failed": false,
    "token": "",
    "source": "",
    "git_suffix": true,
    "name": "my_repo",
    "owner": "/git@bitbucket:7999/MY_ORG",
    "ref": "",
    "filepathtype": "",
    "filepath": "",
    "organization": "/git@bitbucket:7999/MY_ORG",
    "full_name": "/git@bitbucket:7999/MY_ORG/my_repo"
}
@niryarden
Copy link
Author

Important Addition

Something important I have just noticed: This issue Does not reproduce in node, It happens to me in React applications. If you try to add a test to this repo on parsing the URL I've mentioned, the parsing will work.
But using React (didn't check other frameworks), the module cannot parse this URL since version 12.0.0.

Steps to reproduce:

Create a new create-react-app application

npx create-react-app my-app

Add git-url-parse to your project and use it

npm install git-url-parse

and use the module in App.js, for example:

import { useEffect } from 'react';
import gitUrlParse from 'git-url-parse';

function App() {
  useEffect(() => {
    const res = gitUrlParse("ssh://git@bitbucket:7999/MY_ORG/my_repo.git");
    console.log(res);
  }, [])

  return (
    <div />
  );
}

export default App;

Run the app and get the broken parse in the console:

npm start

console:

{
    "protocols": [
        "ssh"
    ],
    "protocol": "ssh",
    "port": "",
    "resource": "",
    "host": "",
    "user": "",
    "password": "",
    "pathname": "//git@bitbucket:7999/MY_ORG/my_repo.git",
    "hash": "",
    "search": "",
    "href": "ssh://git@bitbucket:7999/MY_ORG/my_repo.git",
    "query": {},
    "parse_failed": false,
    "token": "",
    "source": "",
    "git_suffix": true,
    "name": "my_repo",
    "owner": "/git@bitbucket:7999/MY_ORG",
    "ref": "",
    "filepathtype": "",
    "filepath": "",
    "organization": "/git@bitbucket:7999/MY_ORG",
    "full_name": "/git@bitbucket:7999/MY_ORG/my_repo"
}

@niryarden
Copy link
Author

I believe that this might be the issue - IonicaBizau/parse-path@f9ad885#diff-92bbac9a308cd5fcf9db165841f2d90ce981baddcb2b1e26cfff170929af3bd1R40

new URL(url) works properly in nodejs, but seems to behave unexpectedly in browsers.

image

@niryarden
Copy link
Author

found two more links that might be useful:
nodejs/node#36172
honkit/honkit#256

@ahussein3
Copy link

Is there fix-up yet for this issue?

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

Successfully merging a pull request may close this issue.

2 participants