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

duxca.wmurlshortener.js

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

duxca.wmurlshortener.js - npm Package Compare versions

Comparing version 1.4.8 to 1.4.9

119

lib/WMURLShortener.js

@@ -5,4 +5,4 @@ (function(global) {

// --- dependency modules ----------------------------------
var XMLHttpRequest = global["XHRProxy"] || require("uupaa.xhrproxy.js");
var JSON = global["JSON"];
var XHRProxy = global["XHRProxy"] || require("uupaa.xhrproxy.js");
var JSON = global["JSON"];

@@ -43,34 +43,12 @@

var that = this;
(function send(){
var xhr = new XMLHttpRequest();
xhr["on"]("load", function() {
if (200 <= xhr["status"] && xhr["status"] < 300) {
//{@dev
console.info(JSON["stringify"](xhr["response"], null, " "));
//}@dev
if(typeof xhr["response"]["error"] === "undefined"){
callback(null, xhr["response"]["id"]);
}else{
callback(new Error(xhr["response"]["error"]["message"]), "");
}
} else if(xhr["status"] === 403 && that["retryCount"] < that["maximumRetryCount"]){
//{@dev
console.info(""+xhr["status"]+": "+that["retryCount"]+"nth retrying "+(3*2^(that["retryCount"]))+"sec after");
//}@dev
setTimeout(function(){
that["retryCount"]++;
send();
}, 3000*2^(that["retryCount"]));
} else {
//{@dev
console.info(xhr["status"]);
//}@dev
callback(new Error(xhr["status"]), "");
}
});
xhr["open"]('POST', 'https://www.googleapis.com/urlshortener/v1/url', true);
xhr["setRequestHeader"]('Content-Type', 'application/json');
xhr["responseType"] = "json";
xhr["send"](JSON["stringify"]({'longUrl': longUrl}));
}());
var xhr = new XHRProxy();
var retry = WMURLShortener_shorten["bind"](that, longUrl, callback);
xhr["on"]("load", _createListener(that, xhr, retry, function(err){
if(!!err) return callback(err, "");
callback(null, xhr["response"]["id"]);
}));
xhr["open"]('POST', 'https://www.googleapis.com/urlshortener/v1/url', true);
xhr["setRequestHeader"]('Content-Type', 'application/json');
xhr["responseType"] = "json";
xhr["send"](JSON["stringify"]({'longUrl': longUrl}));
}

@@ -86,33 +64,46 @@

var that = this;
(function send(){
var xhr = new XMLHttpRequest();
xhr["on"]("load", function() {
if (200 <= xhr["status"] && xhr["status"] < 300) {
//{@dev
console.info(JSON["stringify"](xhr["response"], null, " "));
//}@dev
if(typeof xhr["response"]["error"] === "undefined"){
callback(null, xhr["response"]["longUrl"]);
}else{
callback(new Error(xhr["response"]["error"]["message"]), "");
}
} else if(xhr["status"] === 403 && that["retryCount"] < that["maximumRetryCount"]){
//{@dev
console.info(""+xhr["status"]+": "+that["retryCount"]+"nth retrying "+(3*2^(that["retryCount"]))+"sec after");
//}@dev
setTimeout(function(){
that["retryCount"]++;
send();
}, 3000*2^(that["retryCount"]));
} else {
//{@dev
console.info(xhr["status"]);
//}@dev
callback(new Error(xhr["status"]), "");
var xhr = new XHRProxy();
var retry = WMURLShortener_expand["bind"](that, shortUrl, callback);
xhr["on"]("load", _createListener(that, xhr, retry, function(err){
if(!!err) return callback(err, "");
callback(null, xhr["response"]["longUrl"]);
}));
xhr["open"]("GET", "https://www.googleapis.com/urlshortener/v1/url?shortUrl=" + shortUrl);
xhr["responseType"] = "json";
xhr["send"]();
}
function _createListener(that, // @arg WMURLShortener
xhr, // @arg XHRProxy
retry, // @arg Function - callback():void
callback) {// @arg Function - callback(err:Error|null):void
// @ret Function - callback():void
//{@dev
$args(_createListener, arguments);
//}@dev
return _listener;
function _listener(){
if (200 <= xhr["status"] && xhr["status"] < 300) {
//{@dev
console.info(JSON["stringify"](xhr["response"], null, " "));
//}@dev
if(typeof xhr["response"]["error"] === "undefined"){
callback(null);
}else{
callback(new Error(xhr["response"]["error"]["message"]));
}
});
xhr["open"]("GET", "https://www.googleapis.com/urlshortener/v1/url?shortUrl=" + shortUrl);
xhr["responseType"] = "json";
xhr["send"]();
}());
} else if(xhr["status"] === 403 && that["retryCount"] <= that["maximumRetryCount"]){
that["retryCount"]++;
var timeout = 3 * Math.pow(2, that["retryCount"]);
console.info(xhr["status"]+": retrying "+timeout+"sec after... " +
that["retryCount"] + "/" + that["maximumRetryCount"]);
setTimeout(retry, timeout);
} else {
//{@dev
console.info(xhr["status"]);
//}@dev
callback(new Error(xhr["status"]));
}
}
}

@@ -119,0 +110,0 @@

@@ -78,3 +78,14 @@ __history = [

}
},
{
"date": "Tue, 21 Oct 2014 11:31:53 GMT",
"total": {
"sloc": 126,
"maintainability": 66.41492204371342
},
"average": {
"sloc": 126,
"maintainability": "66.41"
}
}
]

@@ -78,3 +78,14 @@ [

}
},
{
"date": "Tue, 21 Oct 2014 11:31:53 GMT",
"total": {
"sloc": 126,
"maintainability": 66.41492204371342
},
"average": {
"sloc": 126,
"maintainability": "66.41"
}
}
]

@@ -18,10 +18,10 @@ __report = {

"sloc": {
"physical": 135,
"logical": 71
"physical": 126,
"logical": 64
},
"cyclomatic": 15,
"cyclomatic": 14,
"halstead": {
"operators": {
"distinct": 22,
"total": 211,
"distinct": 23,
"total": 173,
"identifiers": [

@@ -32,4 +32,4 @@ "__stripped__"

"operands": {
"distinct": 78,
"total": 260,
"distinct": 84,
"total": 235,
"identifiers": [

@@ -39,15 +39,15 @@ "__stripped__"

},
"length": 471,
"vocabulary": 100,
"difficulty": 36.66666666666667,
"volume": 3129.2562653838954,
"effort": 114739.39639740951,
"bugs": 1.0430854217946317,
"time": 6374.410910967195
"length": 408,
"vocabulary": 107,
"difficulty": 32.172619047619044,
"volume": 2750.5185304516676,
"effort": 88491.38486363846,
"bugs": 0.9168395101505559,
"time": 4916.188047979915
},
"params": 8
"params": 14
}
},
"module": "lib/WMURLShortener.js",
"maintainability": 67.00267904468714
"maintainability": 66.41492204371342
}

@@ -58,10 +58,10 @@ }

"total": {
"sloc": 135,
"maintainability": 67.00267904468714
"sloc": 126,
"maintainability": 66.41492204371342
},
"average": {
"sloc": 135,
"maintainability": "67.00"
"sloc": 126,
"maintainability": "66.41"
}
}
}

@@ -18,10 +18,10 @@ {

"sloc": {
"physical": 135,
"logical": 71
"physical": 126,
"logical": 64
},
"cyclomatic": 15,
"cyclomatic": 14,
"halstead": {
"operators": {
"distinct": 22,
"total": 211,
"distinct": 23,
"total": 173,
"identifiers": [

@@ -32,4 +32,4 @@ "__stripped__"

"operands": {
"distinct": 78,
"total": 260,
"distinct": 84,
"total": 235,
"identifiers": [

@@ -39,15 +39,15 @@ "__stripped__"

},
"length": 471,
"vocabulary": 100,
"difficulty": 36.66666666666667,
"volume": 3129.2562653838954,
"effort": 114739.39639740951,
"bugs": 1.0430854217946317,
"time": 6374.410910967195
"length": 408,
"vocabulary": 107,
"difficulty": 32.172619047619044,
"volume": 2750.5185304516676,
"effort": 88491.38486363846,
"bugs": 0.9168395101505559,
"time": 4916.188047979915
},
"params": 8
"params": 14
}
},
"module": "lib/WMURLShortener.js",
"maintainability": 67.00267904468714
"maintainability": 66.41492204371342
}

@@ -58,10 +58,10 @@ }

"total": {
"sloc": 135,
"maintainability": 67.00267904468714
"sloc": 126,
"maintainability": 66.41492204371342
},
"average": {
"sloc": 135,
"maintainability": "67.00"
"sloc": 126,
"maintainability": "66.41"
}
}
}
{
"name": "duxca.wmurlshortener.js",
"version": "1.4.8",
"version": "1.4.9",
"description": "URL Shortener using goo.gl",

@@ -5,0 +5,0 @@ "url": "https://github.com/duxca/WMURLShortener.js",

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