Skip to content

Commit

Permalink
fix: domains with - were not loading the keywords.
Browse files Browse the repository at this point in the history
resolves: #11
  • Loading branch information
towfiqi committed Dec 2, 2022
1 parent a11b0f2 commit efb565b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pages/api/domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
Expand Down
2 changes: 1 addition & 1 deletion pages/api/keywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
Expand Down

0 comments on commit efb565b

Please sign in to comment.