Last active
August 29, 2015 14:25
-
-
Save fgandellini/4b868198b6cedf4d51eb to your computer and use it in GitHub Desktop.
check link
This file contains 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 check(link) { | |
var errorMessage = 'Mumble mumble... this seems to be an invalid link! :('; | |
return new Promise(function(resolve, reject) { | |
try { | |
http.request(link, function(res) { | |
debug('link status is ', res.statusCode); | |
if (res.statusCode !== 404) { | |
resolve(link); | |
} else { | |
reject(errorMessage); | |
} | |
}).end(); | |
} catch(ex) { | |
reject(errorMessage); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment