Created
April 18, 2020 02:46
-
-
Save J3698/31fdf73ef0f189382b5fae6fabf9944e to your computer and use it in GitHub Desktop.
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
// GET route for custom URLs | |
app.get('/custom', (req, res) => { | |
// sanitize input | |
if (typeof (req.query.longUrl) !== "string" || | |
typeof (req.query.customUrl) !== "string") { | |
res.send({"shortened": null}); | |
return; | |
} | |
let longUrl = qualify(req.query.longUrl); | |
let customUrl = req.query.customUrl; | |
if (customWordUnavailable(longUrl, customUrl)) { | |
res.send({"shortened": null}); | |
} else { | |
customUrl = createCustomMapping(longUrl, customUrl); | |
res.send({"shortened": customUrl}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment