isomorphic-git 1.40.6 → 1.40.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3097,8 +3097,10 @@ class UrlParseError extends BaseError {
3097
3097
  UrlParseError.code = 'UrlParseError';
3098
3098
 
3099
3099
  function translateSSHtoHTTP(url) {
3100
- // handle "shorter scp-like syntax"
3101
- url = url.replace(/^git@([^:]+):/, 'https://$1/');
3100
+ // handle "shorter scp-like syntax". The user is dropped: it names an ssh
3101
+ // account and means nothing over https, which is what the old expression did
3102
+ // for `git@` too.
3103
+ url = url.replace(/^[^/@:]+@([^/@:]+):/, 'https://$1/');
3102
3104
  // handle proper SSH URLs
3103
3105
  url = url.replace(/^ssh:\/\//, 'https://');
3104
3106
  return url
@@ -3145,9 +3147,15 @@ class GitRemoteManager {
3145
3147
  * @param {string} args.url - The URL of the remote repository.
3146
3148
  * @returns {Object|undefined} - An object containing the transport and address, or undefined if parsing fails.
3147
3149
  */
3150
+ // git-clone(1) calls this the "shorter scp-like syntax": [user@]host:path. The
3151
+ // user is part of the syntax, not part of the word `git`, and a self-hosted
3152
+ // forge is as likely to hand out `gitolite@`, `forgejo@` or `ubuntu@`. The host
3153
+ // and the user cannot hold a slash, an at sign or a colon, so `https://x` and a
3154
+ // `scheme:address` override are left to the expression below.
3155
+ const scpLike = /^[^/@:]+@[^/@:]+:/;
3156
+
3148
3157
  function parseRemoteUrl({ url }) {
3149
- // the stupid "shorter scp-like syntax"
3150
- if (url.startsWith('git@')) {
3158
+ if (scpLike.test(url)) {
3151
3159
  return {
3152
3160
  transport: 'ssh',
3153
3161
  address: url,
package/managers/index.js CHANGED
@@ -3090,8 +3090,10 @@ class UrlParseError extends BaseError {
3090
3090
  UrlParseError.code = 'UrlParseError';
3091
3091
 
3092
3092
  function translateSSHtoHTTP(url) {
3093
- // handle "shorter scp-like syntax"
3094
- url = url.replace(/^git@([^:]+):/, 'https://$1/');
3093
+ // handle "shorter scp-like syntax". The user is dropped: it names an ssh
3094
+ // account and means nothing over https, which is what the old expression did
3095
+ // for `git@` too.
3096
+ url = url.replace(/^[^/@:]+@([^/@:]+):/, 'https://$1/');
3095
3097
  // handle proper SSH URLs
3096
3098
  url = url.replace(/^ssh:\/\//, 'https://');
3097
3099
  return url
@@ -3138,9 +3140,15 @@ class GitRemoteManager {
3138
3140
  * @param {string} args.url - The URL of the remote repository.
3139
3141
  * @returns {Object|undefined} - An object containing the transport and address, or undefined if parsing fails.
3140
3142
  */
3143
+ // git-clone(1) calls this the "shorter scp-like syntax": [user@]host:path. The
3144
+ // user is part of the syntax, not part of the word `git`, and a self-hosted
3145
+ // forge is as likely to hand out `gitolite@`, `forgejo@` or `ubuntu@`. The host
3146
+ // and the user cannot hold a slash, an at sign or a colon, so `https://x` and a
3147
+ // `scheme:address` override are left to the expression below.
3148
+ const scpLike = /^[^/@:]+@[^/@:]+:/;
3149
+
3141
3150
  function parseRemoteUrl({ url }) {
3142
- // the stupid "shorter scp-like syntax"
3143
- if (url.startsWith('git@')) {
3151
+ if (scpLike.test(url)) {
3144
3152
  return {
3145
3153
  transport: 'ssh',
3146
3154
  address: url,