Skip to content

Commit

Permalink
Fix private urls using colon separator
Browse files Browse the repository at this point in the history
Closes #573, closes #2416.

Related to #2384, #573.
  • Loading branch information
Balthazar Gronon committed Jan 26, 2017
1 parent ddb9fa8 commit 28835f4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 13 additions & 5 deletions src/resolvers/exotics/git-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:'];
Expand Down Expand Up @@ -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<?Manifest> {
Expand All @@ -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,
};
Expand All @@ -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));
}
}
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 28835f4

Please sign in to comment.