Closed thangngoc89 closed 9 years ago
I'm just being stupid. URI.withinString doesn't work with async.
Here is my solution:
var data = req.body;
var getUrlRegEx = new RegExp(
"(^|[ \t\r\n])((ftp|http|https|gopher|mailto|news|nntp|telnet|wais|file|prospero|aim|webcal):(([A-Za-z0-9$_.+!*(),;/?:@&~=-])|%[A-Fa-f0-9]{2}){2,}(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*(),;/?:@&~=%-]*))?([A-Za-z0-9$_+!*();/?:~-]))"
, "g"
);
var urls = data.match(getUrlRegEx);
async.forEachLimit(urls, 5, function (url, callback) {
let w = new Bypasser(url);
w.decrypt(function (err, res) {
if (err == null && res != undefined) {
data = data.replace(url, res);
callback();
}
});
}, function(err) {
res.send(data);
});
The second approach seems ok but I wouldn't use let
for the bypasser instance.
Thanks for the heads up.
With this great project. I can unshorten thousands of short links in just 10 minutes. And my IP was banned. I do need to improve my JS skill more
I'm building a app that uses
node-bypasser
but how can I return result fromBypasser.descrypt
?Here is my code: