New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bitly

Package Overview
Dependencies
Maintainers
1
Versions
124
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitly - npm Package Compare versions

Comparing version 5.0.11 to 5.0.12-beta.786

39

dist/bitly.js

@@ -361,2 +361,8 @@ module.exports =

*/
var DEFAULT_OPTIONS = {
apiUrl: 'api-ssl.bitly.com',
apiVersion: 'v3',
domain: 'bit.ly',
format: 'json'
};
/**

@@ -374,8 +380,8 @@ * Generates a valid URL for a GET request to the Bit.ly API

*/
var generateUrl = function (accessToken, method, data, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.apiUrl, apiUrl = _c === void 0 ? 'api-ssl.bitly.com' : _c, _d = _b.apiVersion, apiVersion = _d === void 0 ? 'v3' : _d, _e = _b.domain, domain = _e === void 0 ? 'bit.ly' : _e, _f = _b.format, format = _f === void 0 ? 'json' : _f;
var generateUrl = function (accessToken, method, data, config) {
if (config === void 0) { config = {}; }
var newQuery = Object.assign({
access_token: accessToken,
domain: domain,
format: format,
domain: config.domain || DEFAULT_OPTIONS.domain,
format: config.format || DEFAULT_OPTIONS.format,
});

@@ -385,4 +391,4 @@ Object.keys(data || []).forEach(function (key) { return (newQuery[key] = data[key]); });

protocol: 'https',
hostname: apiUrl,
pathname: "/" + apiVersion + "/" + method,
hostname: config.apiUrl || DEFAULT_OPTIONS.apiUrl,
pathname: "/" + (config.apiVersion || DEFAULT_OPTIONS.apiVersion) + "/" + method,
query: newQuery,

@@ -411,3 +417,5 @@ }));

_b.trys.push([1, 3, , 4]);
return [4 /*yield*/, request({ uri: uri })];
return [4 /*yield*/, request({
uri: uri
})];
case 2:

@@ -425,10 +433,13 @@ req = _b.sent();

/**
* Function to check through an array of items to check for short urls or hashes
* If only passed one item, put in array for url checking
* @param {Array<string>} unsortedItems The array of items to be checked
* @param {object} query The query object
* @return {object}
*/
* Function to check through an array of items to check for short urls or hashes
* If only passed one item, put in array for url checking
* @param {Array<string>} unsortedItems The array of items to be checked
* @param {object} query The query object
* @return {object}
*/
var sortUrlsAndHash = function (unsortedItems, result) {
if (result === void 0) { result = { shortUrl: [], hash: [] }; }
if (result === void 0) { result = {
shortUrl: [],
hash: []
}; }
(Array.isArray(unsortedItems) ? unsortedItems : [unsortedItems]).map(function (item) {

@@ -435,0 +446,0 @@ return isUri(item) ? result.shortUrl.push(item) : typeof item === 'string' && result.hash.push(item);

@@ -12,3 +12,3 @@ {

"homepage": "https://github.com/tanepiper/node-bitly",
"version": "5.0.11",
"version": "5.0.12-beta.786",
"author": {

@@ -15,0 +15,0 @@ "name": "Tane Piper",

@@ -30,3 +30,3 @@ # node-bitly - Bitly API for nodejs

const BitlyClient = require('bitly');
const bitly = BitleyClient('<accessToken>');
const bitly = BitlyClient('<accessToken>');

@@ -44,3 +44,3 @@ try {

const BitlyClient = require('bitly');
const bitly = BitleyClient('<accessToken>');
const bitly = BitlyClient('<accessToken>');

@@ -61,3 +61,3 @@ bitly.shorten('https://github.com/tanepiper/node-bitly')

const BitlyClient = require('bitly');
const bitly = BitleyClient('<accessToken>');
const bitly = BitlyClient('<accessToken>');

@@ -64,0 +64,0 @@ try {

@@ -11,2 +11,9 @@ const url = require('url');

const DEFAULT_OPTIONS = {
apiUrl: 'api-ssl.bitly.com',
apiVersion: 'v3',
domain: 'bit.ly',
format: 'json'
};
/**

@@ -28,8 +35,8 @@ * Generates a valid URL for a GET request to the Bit.ly API

data,
{ apiUrl = 'api-ssl.bitly.com', apiVersion = 'v3', domain = 'bit.ly', format = 'json' } = {},
config = {},
) => {
const newQuery = Object.assign({
access_token: accessToken,
domain,
format,
domain: config.domain || DEFAULT_OPTIONS.domain,
format: config.format || DEFAULT_OPTIONS.format,
});

@@ -42,4 +49,4 @@

protocol: 'https',
hostname: apiUrl,
pathname: `/${apiVersion}/${method}`,
hostname: config.apiUrl || DEFAULT_OPTIONS.apiUrl,
pathname: `/${config.apiVersion || DEFAULT_OPTIONS.apiVersion}/${method}`,
query: newQuery,

@@ -59,6 +66,13 @@ }),

*/
const doRequest = async ({ accessToken, method, data, config }) => {
const doRequest = async ({
accessToken,
method,
data,
config
}) => {
const uri = generateUrl(accessToken, method, data, config);
try {
const req = await request({ uri });
const req = await request({
uri
});
return JSON.parse(req);

@@ -71,12 +85,15 @@ } catch (error) {

/**
* Function to check through an array of items to check for short urls or hashes
* If only passed one item, put in array for url checking
* @param {Array<string>} unsortedItems The array of items to be checked
* @param {object} query The query object
* @return {object}
*/
const sortUrlsAndHash = (unsortedItems, result = { shortUrl: [], hash: [] }) => {
* Function to check through an array of items to check for short urls or hashes
* If only passed one item, put in array for url checking
* @param {Array<string>} unsortedItems The array of items to be checked
* @param {object} query The query object
* @return {object}
*/
const sortUrlsAndHash = (unsortedItems, result = {
shortUrl: [],
hash: []
}) => {
(Array.isArray(unsortedItems) ? unsortedItems : [unsortedItems]).map(
item =>
isUri(item) ? result.shortUrl.push(item) : typeof item === 'string' && result.hash.push(item),
isUri(item) ? result.shortUrl.push(item) : typeof item === 'string' && result.hash.push(item),
);

@@ -83,0 +100,0 @@ return result;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc