fix: domains with - were not loading the keywords.

resolves: #11
This commit is contained in:
Towfiq
2022-12-02 07:36:09 +06:00
parent a11b0f223c
commit efb565ba00
2 changed files with 3 additions and 3 deletions

View File

@@ -61,8 +61,8 @@ export const addDomain = async (req: NextApiRequest, res: NextApiResponse<Domain
}
const { domain } = req.body || {};
const domainData = {
domain,
slug: domain.replaceAll('.', '-'),
domain: domain.trim(),
slug: domain.trim().replaceAll('-', '_').replaceAll('.', '-'),
lastUpdated: new Date().toJSON(),
added: new Date().toJSON(),
};

View File

@@ -44,7 +44,7 @@ const getKeywords = async (req: NextApiRequest, res: NextApiResponse<KeywordsGet
if (!req.query.domain && typeof req.query.domain !== 'string') {
return res.status(400).json({ error: 'Domain is Required!' });
}
const domain = (req.query.domain as string).replaceAll('-', '.');
const domain = (req.query.domain as string).replaceAll('-', '.').replaceAll('_', '-');
try {
const allKeywords:Keyword[] = await Keyword.findAll({ where: { domain } });