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

Parsing SSH URL of repository fails when it contains URL-encoded spaces (%20) #162

Open
thomas-jakemeyn opened this issue Sep 4, 2023 · 1 comment

Comments

@thomas-jakemeyn
Copy link

The parsing of a repository URL fails when it uses the SSH protocol and contains URL-encoded spaces (aka %20).

The problem can be reproduced with git-url-parse version 13.1.0 (aka the latest version at the moment of writing this issue).

const gitUrlParse = require('git-url-parse');

function test(description, url) {
  try {
    gitUrlParse(url);
    console.log(`SUCCESS: ${description}`);
  } catch (error) {
    console.log(`FAILURE: ${description}`);
  }
}

test('SSH URL with URL-encoded spaces', 'git@ssh.dev.azure.com:v3/ORG/My%20project/repo');
test('SSH URL with non URL-encoded spaces', 'git@ssh.dev.azure.com:v3/ORG/My project/repo');
test('SSH URL without spaces', 'git@ssh.dev.azure.com:v3/ORG/My-project/repo');
test('HTTPS URL with URL-encoded spaces', 'https://ORG@dev.azure.com/ORG/My%20project/_git/repo');
test('HTTPS URL with non URL-encoded spaces', 'https://ORG@dev.azure.com/ORG/My project/_git/repo');
test('HTTPS URL without spaces', 'https://ORG@dev.azure.com/ORG/My-project/_git/repo');

// Results:
// FAILURE: SSH URL with URL-encoded spaces
// FAILURE: SSH URL with non URL-encoded spaces
// SUCCESS: SSH URL without spaces
// SUCCESS: HTTPS URL with URL-encoded spaces
// SUCCESS: HTTPS URL with non URL-encoded spaces
// SUCCESS: HTTPS URL without spaces
@thomas-jakemeyn
Copy link
Author

thomas-jakemeyn commented Jan 8, 2024

Fixing this bug requires updating git-up to use the latest version of parse-url (9.0.0+) where the actual root cause of this problem has been fixed (see IonicaBizau/parse-url#75).

git-url-parse
  |_ git-up
    |_ parse-url 

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

No branches or pull requests

1 participant