-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from tanish35/master
Added custom .json file to add more domains
- Loading branch information
Showing
3 changed files
with
28 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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 { | ||
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]; | ||
|
||
// Check if the email domain is in the list of college domains | ||
return domains.includes(emailDomain); | ||
} | ||
|
||
export default checkCollegeEmail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
"aec.edu", | ||
"jadavpuruniversity.in", | ||
"anothercollege.edu" | ||
] | ||
|