Skip to content

Commit

Permalink
Fix the package being broken from npm API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 5, 2020
1 parent 8683470 commit e6c5166
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
'use strict';
const {URL} = require('url');
const got = require('got');
const registryUrl = require('registry-url');
const getRegistryUrl = require('registry-url');

const npmEmail = async username => {
if (typeof username !== 'string') {
throw new TypeError('Username required');
}

const url = new URL(`${registryUrl()}-/user/org.couchdb.user:${username}`);
let registryUrl = getRegistryUrl();

// `npmjs.com` no longer supports the endpoint we need, so we use a mirror.
if (registryUrl.trim().replace(/\/$/, '') === 'https://registry.npmjs.org') {
registryUrl = 'https://r.cnpmjs.org/';
}

const url = new URL(`${registryUrl}-/user/org.couchdb.user:${username}`);

try {
const {body} = await got(url, {json: true});
Expand Down

0 comments on commit e6c5166

Please sign in to comment.