1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-19 05:09:41 +02:00

Handled query params for aliases (#90)

This commit is contained in:
DorofeevMark 2019-04-16 13:00:19 +03:00 committed by GitHub
parent 6ac5c71e26
commit 36c6b89023
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,7 +12,14 @@ const verifyToken = require('./middlewares/token');
*/
router.get('*', verifyToken, async (req, res) => {
try {
const alias = await Aliases.get(req.originalUrl.slice(1)); // Cuts first '/' character
let url = req.originalUrl.slice(1); // Cuts first '/' character
const queryParamsIndex = url.indexOf('?');
if (queryParamsIndex !== -1) {
url = url.slice(0, queryParamsIndex); // Cuts off query params
}
const alias = await Aliases.get(url);
switch (alias.type) {
case Alias.types.PAGE: {