Created
April 9, 2018 20:39
-
-
Save nickpalenchar/940f9671fe17a9b541c7bf9b595d9f71 to your computer and use it in GitHub Desktop.
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
router.post('/new-link', requireAuthentication, (req, res) => { | |
let { expandedUrl, customName } = req.body; | |
if(!/^https?:\/\//.test(expandedUrl)) expandedUrl = "http://" + expandedUrl; // add `http://` if not already provided, for consistency. | |
tryLink() | |
.then(result => { | |
res.redirect('/dashboard?success=' + JSON.stringify(result)); | |
}) | |
.catch( err => { | |
if(err.nick) res.render('error', {err} ); | |
else res.redirect('/error?code=1'); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment