Skip to content

Commit

Permalink
put .json instead of .txt for email domains
Browse files Browse the repository at this point in the history
  • Loading branch information
tanish35 committed Jul 30, 2024
1 parent 1dd1db7 commit 880f9bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
10 changes: 5 additions & 5 deletions backend/src/mail/checkAcademic.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import fs from 'fs';
import path from 'path';

// Get the directory name of the current module
const __dirname = path.resolve(); // CommonJS way to get the directory path

// Function to check if an email has a valid college domain
function checkCollegeEmail(email: string): boolean {
// Get the directory name of the current module
const __dirname = path.resolve(); // CommonJS way to get the directory path

const filePath = path.join(__dirname, '/src/mail/emails.txt');
const domains = fs.readFileSync(filePath, 'utf8').split('\n').map(domain => domain.trim());
const filePath = path.join(__dirname, 'emails.json');
const domains = JSON.parse(fs.readFileSync(filePath, 'utf8'));

// Extract the domain from the email
const emailDomain = email.split('@')[1];
Expand Down
6 changes: 6 additions & 0 deletions backend/src/mail/emails.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
"aec.edu",
"jadavpuruniversity.in",
"anothercollege.edu"
]

4 changes: 0 additions & 4 deletions backend/src/mail/emails.txt

This file was deleted.

0 comments on commit 880f9bf

Please sign in to comment.