mirror of
https://github.com/juherr/kill-the-news.git
synced 2026-06-20 22:03:48 +00:00
Enhance admin interface, security, and feed management with improved UX and authentication
This commit is contained in:
@@ -6,11 +6,12 @@ import { EmailData } from '../types';
|
||||
export class EmailParser {
|
||||
/**
|
||||
* Extract the feed ID from an email address
|
||||
* @param emailAddress The email address (e.g., newsletter-xyz@domain.com)
|
||||
* @param emailAddress The email address (e.g., apple.mountain.42@domain.com)
|
||||
* @returns The feed ID or null if not found
|
||||
*/
|
||||
static extractFeedId(emailAddress: string): string | null {
|
||||
const match = emailAddress.match(/^newsletter-([a-zA-Z0-9]+)@/);
|
||||
// Match pattern for noun1.noun2.XY before the @ symbol
|
||||
const match = emailAddress.match(/^([a-z]+\.[a-z]+\.\d{2})@/i);
|
||||
return match ? match[1] : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { nouns } from '../data/nouns';
|
||||
|
||||
/**
|
||||
* Generates a random feed ID in the format noun1.noun2.XY
|
||||
* @returns A random feed ID string
|
||||
*/
|
||||
export function generateFeedId(): string {
|
||||
// Select two random nouns
|
||||
const noun1 = nouns[Math.floor(Math.random() * nouns.length)];
|
||||
const noun2 = nouns[Math.floor(Math.random() * nouns.length)];
|
||||
|
||||
// Generate a random 2-digit number between 10 and 99
|
||||
const number = Math.floor(Math.random() * 90) + 10;
|
||||
|
||||
// Combine to create the ID with dots as separators
|
||||
return `${noun1}.${noun2}.${number}`;
|
||||
}
|
||||
Reference in New Issue
Block a user