diff --git a/package.json b/package.json index 7f0579d08e..57de2128c0 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "eslint-plugin-no-async-without-await": "^1.0.0", "eslint-plugin-react": "5.2.2", "eslint-plugin-yarn-internal": "file:scripts/eslint-rules", - "flow-bin": "^0.37.3", + "flow-bin": "^0.38.0", "gulp": "^3.9.0", "gulp-babel": "^6.0.0", "gulp-if": "^2.0.1", diff --git a/src/resolvers/exotics/git-resolver.js b/src/resolvers/exotics/git-resolver.js index bc2e32877a..8a758980f4 100644 --- a/src/resolvers/exotics/git-resolver.js +++ b/src/resolvers/exotics/git-resolver.js @@ -11,6 +11,7 @@ import ExoticResolver from './exotic-resolver.js'; import Git from '../../util/git.js'; const urlParse = require('url').parse; +const urlFormat = require('url').format; // we purposefully omit https and http as those are only valid if they end in the .git extension const GIT_PROTOCOLS = ['git:', 'git+ssh:', 'git+https:', 'ssh:']; @@ -92,7 +93,14 @@ export default class GitResolver extends ExoticResolver { } const {config} = this; - const client = new Git(config, url, this.hash); + + if (parts.pathname) { + parts.pathname = parts.pathname.replace(/^\/:/, '/'); + } + + const transformedUrl = urlFormat(parts); + + const client = new Git(config, transformedUrl, this.hash); const commit = await client.init(); async function tryRegistry(registry): Promise { @@ -103,12 +111,12 @@ export default class GitResolver extends ExoticResolver { return null; } - const json = await config.readJson(`${url}/${filename}`, () => JSON.parse(file)); + const json = await config.readJson(`${transformedUrl}/${filename}`, () => JSON.parse(file)); json._uid = commit; json._remote = { - resolved: `${url}#${commit}`, + resolved: `${transformedUrl}#${commit}`, type: 'git', - reference: url, + reference: transformedUrl, hash: commit, registry, }; @@ -131,6 +139,6 @@ export default class GitResolver extends ExoticResolver { } } - throw new MessageError(this.reporter.lang('couldntFindManifestIn', url)); + throw new MessageError(this.reporter.lang('couldntFindManifestIn', transformedUrl)); } } diff --git a/yarn.lock b/yarn.lock index 129a72ec6c..74ba384f30 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2212,8 +2212,8 @@ flat-cache@^1.2.1: write "^0.2.1" flow-bin: - version "0.37.3" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.37.3.tgz#68e5841606a2be6929793ec9c4ce08b2ea39d7c2" + version "0.38.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.38.0.tgz#68e5841606a2be6929793ec9c4ce08b2ea39d7c2" for-in@^0.1.5: version "0.1.6"