💾 Archived View for iich.space › src › middleware › withDomainValidation.ts captured on 2022-03-01 at 16:00:04.
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
import { Handler } from '~/gemini'; const withDomainValidation: Handler = (req, res) => { const parts = req.url.hostname.toLowerCase().split('.'); if (parts.length === 1) { const [host] = parts; if (host === 'localhost') { return; } } if (parts.length === 2) { const [host] = parts; if (host === 'iich') { return; } } if (parts.length === 3) { const LOCALE_WHITELIST = ['en', 'ru']; const [locale, host] = parts; if (host === 'iich' && LOCALE_WHITELIST.includes(locale)) { return; } } res.notFound(); }; export default withDomainValidation;