{"action":"created","issue":{"url":"https://api.github.com/repos/matteocontrini/node-bypasser/issues/20","labels_url":"https://api.github.com/repos/matteocontrini/node-bypasser/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/matteocontrini/node-bypasser/issues/20/comments","events_url":"https://api.github.com/repos/matteocontrini/node-bypasser/issues/20/events","html_url":"https://github.com/matteocontrini/node-bypasser/issues/20","id":116496615,"number":20,"title":"Node-bypasser in action","user":{"login":"thangngoc89","id":3049054,"avatar_url":"https://avatars.githubusercontent.com/u/3049054?v=3","gravatar_id":"","url":"https://api.github.com/users/thangngoc89","html_url":"https://github.com/thangngoc89","followers_url":"https://api.github.com/users/thangngoc89/followers","following_url":"https://api.github.com/users/thangngoc89/following{/other_user}","gists_url":"https://api.github.com/users/thangngoc89/gists{/gist_id}","starred_url":"https://api.github.com/users/thangngoc89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thangngoc89/subscriptions","organizations_url":"https://api.github.com/users/thangngoc89/orgs","repos_url":"https://api.github.com/users/thangngoc89/repos","events_url":"https://api.github.com/users/thangngoc89/events{/privacy}","received_events_url":"https://api.github.com/users/thangngoc89/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/matteocontrini/node-bypasser/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-12T07:37:42Z","updated_at":"2015-11-12T11:09:55Z","closed_at":"2015-11-12T11:09:55Z","body":"I'm building a app that uses `node-bypasser` but how can I return result from `Bypasser.descrypt` ?\r\n\r\nHere is my code:\r\n\r\n```javascript\r\nvar Bypasser = require('node-bypasser');\r\nvar URI = require('urijs');\r\n\r\nvar data = 'multiple urls : http://adf.ly/1DX0XD http://l.khoanguyen.me';\r\n\r\nvar result = URI.withinString(data, function(url) {\r\n    var unshortenedUrl = null;\r\n   \r\n    var w = new Bypasser(url);\r\n    w.decrypt(function(err, res) {\r\n      // How can I return res ?\r\n      unshortenedUrl = res;\r\n    });\r\n    // I know the w.descrypt function is a asynchronous function\r\n    // so unshortenedUrl = null\r\n    return unshortenedUrl;\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/matteocontrini/node-bypasser/issues/comments/156076221","html_url":"https://github.com/matteocontrini/node-bypasser/issues/20#issuecomment-156076221","issue_url":"https://api.github.com/repos/matteocontrini/node-bypasser/issues/20","id":156076221,"user":{"login":"thangngoc89","id":3049054,"avatar_url":"https://avatars.githubusercontent.com/u/3049054?v=3","gravatar_id":"","url":"https://api.github.com/users/thangngoc89","html_url":"https://github.com/thangngoc89","followers_url":"https://api.github.com/users/thangngoc89/followers","following_url":"https://api.github.com/users/thangngoc89/following{/other_user}","gists_url":"https://api.github.com/users/thangngoc89/gists{/gist_id}","starred_url":"https://api.github.com/users/thangngoc89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thangngoc89/subscriptions","organizations_url":"https://api.github.com/users/thangngoc89/orgs","repos_url":"https://api.github.com/users/thangngoc89/repos","events_url":"https://api.github.com/users/thangngoc89/events{/privacy}","received_events_url":"https://api.github.com/users/thangngoc89/received_events","type":"User","site_admin":false},"created_at":"2015-11-12T11:09:55Z","updated_at":"2015-11-12T11:09:55Z","body":"I'm just being stupid.\r\nURI.withinString doesn't work with async.\r\n\r\nHere is my solution:\r\n\r\n```javascript\r\nvar data = req.body;\r\n\r\n      var getUrlRegEx = new RegExp(\r\n        \"(^|[ \\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$_+!*();/?:~-]))\"\r\n        , \"g\"\r\n      );\r\n\r\n      var urls = data.match(getUrlRegEx);\r\n\r\n      async.forEachLimit(urls, 5, function (url, callback) {\r\n        let w = new Bypasser(url);\r\n        w.decrypt(function (err, res) {\r\n          if (err == null && res != undefined) {\r\n            data = data.replace(url, res);\r\n            callback();\r\n          }\r\n        });\r\n      }, function(err) {\r\n        res.send(data);\r\n      });\r\n```"}}