const safeRedirect = (req, res, value, fallback = '/') => {
    if (typeof value === 'string') {
        try {
            const base = `${req.protocol}://${req.get('host')}`;
            const url = new URL(value, base);
            if (url.origin === base) {
                return res.redirect(url.pathname + url.search + url.hash);
            }
        }
        catch {
            return res.redirect('/');
        }
    }
    return res.redirect(fallback);
};

export { safeRedirect };
//# sourceMappingURL=safeRedirect.js.map
