Skip to content

Commit

Permalink
Remove workaround replacing ':' in git URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Apr 3, 2017
1 parent 5561dfb commit f2132be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 61 deletions.
45 changes: 0 additions & 45 deletions __tests__/resolvers/exotics/git-resolver.js

This file was deleted.

21 changes: 5 additions & 16 deletions src/resolvers/exotics/git-resolver.js
Expand Up @@ -11,7 +11,6 @@ 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 @@ -61,14 +60,6 @@ export default class GitResolver extends ExoticResolver {
return false;
}

// This transformUrl util is here to replace colon separators in the pathname
// from private urls. It takes the url parts retrieved using urlFormat and
// returns the associated url. Related to #573, introduced in #2519.
static transformUrl(parts) : string {
const pathname = parts.pathname ? parts.pathname.replace(/^\/:/, '/') : '';
return urlFormat({...parts, pathname});
}

async resolve(forked?: true): Promise<Manifest> {
const {url} = this;

Expand Down Expand Up @@ -102,9 +93,7 @@ export default class GitResolver extends ExoticResolver {

const {config} = this;

const transformedUrl = GitResolver.transformUrl(parts);

const client = new Git(config, transformedUrl, this.hash);
const client = new Git(config, url, this.hash);
const commit = await client.init();

async function tryRegistry(registry): Promise<?Manifest> {
Expand All @@ -115,12 +104,12 @@ export default class GitResolver extends ExoticResolver {
return null;
}

const json = await config.readJson(`${transformedUrl}/${filename}`, () => JSON.parse(file));
const json = await config.readJson(`${url}/${filename}`, () => JSON.parse(file));
json._uid = commit;
json._remote = {
resolved: `${transformedUrl}#${commit}`,
resolved: `${url}#${commit}`,
type: 'git',
reference: transformedUrl,
reference: url,
hash: commit,
registry,
};
Expand All @@ -143,6 +132,6 @@ export default class GitResolver extends ExoticResolver {
}
}

throw new MessageError(this.reporter.lang('couldntFindManifestIn', transformedUrl));
throw new MessageError(this.reporter.lang('couldntFindManifestIn', url));
}
}

0 comments on commit f2132be

Please sign in to comment.