ericf / express-slash

Express middleware for people who are anal about trailing slashes.
MIT License
155 stars 13 forks source link

infinit redirect with parameter #12

Open xileftenurb opened 5 years ago

xileftenurb commented 5 years ago

Hi, I found a bug, I have this route that cause problem with the slash package

router.get('/restaurant-:resto', function (req, res, next) {
    const restoMain = req.data.resto.find(r => r.permalink === req.params.resto);
    if (restoMain) {
        res.render('fr/pages/contact-fiche', Object.assign({ apiKey: settings.apiKey, restoMain: restoMain,
            hreflang : "/en/restaurant-" + req.params.resto
        }, paramsBase, req.data));
    } else {
        next();
    }
});

If the resto is find, all good. but if not, it call "next()", and it go in a infinite redirect loop between "/restaurant-test" and "/restaurant-test/"