Created
February 11, 2014 13:32
-
-
Save dai-shi/8934864 to your computer and use it in GitHub Desktop.
URLのリダイレクトをたどる #rsspipes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function rssPipesFilterFunction(articles) { | |
| var promises = []; | |
| articles.forEach(function(article) { | |
| var maxRedirects = 5; | |
| var loop = function() { | |
| var promise = getRedirectURL(article.link).then(function(link) { | |
| if (article.link === link || --maxRedirects < 0) { | |
| return article; | |
| } else { | |
| article.link = link; | |
| return loop(); | |
| } | |
| }); | |
| return promise; | |
| }; | |
| promises.push(loop()); | |
| }); | |
| return Q.all(promises); | |
| } | |
| /* | |
| * Copyright (c) 2014 Daishi Kato | |
| * Licensed under the MIT License | |
| * http://www.opensource.org/licenses/mit-license.php | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment