test(lists): improve test coverage and extract list ID parsing
- Extract extractListId to src/lib/extract-list-id.ts with proper tests - Add json-full/includeRaw test for list timeline - Add 404 retry tests for getOwnedLists and getListMemberships - Add tests for skipping invalid list entries and missing owner handling - Use shared TwitterClientPrivate type from fixtures 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
committed by
Peter Steinberger
co-authored by
Claude Opus 4.5
parent
7818440d65
commit
59e827e153
@@ -0,0 +1,20 @@
|
||||
// ABOUTME: Extract list ID from an X/Twitter list URL.
|
||||
// ABOUTME: Returns list ID or null if input is invalid.
|
||||
|
||||
const LIST_URL_REGEX = /(?:twitter\.com|x\.com)\/i\/lists\/(\d+)/i;
|
||||
const LIST_ID_REGEX = /^\d{5,}$/;
|
||||
|
||||
export function extractListId(input: string): string | null {
|
||||
const trimmed = input.trim();
|
||||
if (!trimmed) {
|
||||
return null;
|
||||
}
|
||||
const urlMatch = LIST_URL_REGEX.exec(trimmed);
|
||||
if (urlMatch) {
|
||||
return urlMatch[1];
|
||||
}
|
||||
if (LIST_ID_REGEX.test(trimmed)) {
|
||||
return trimmed;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user