Merge PR #48: feat: add Xiaohongshu source + Reddit public fallback
- Xiaohongshu search via local MCP service (opt-in, zero impact if service not running) - Reddit public JSON fallback (works with zero API keys) - Reddit priority: ScrapeCreators -> OpenAI -> public fallback - Updated env.py: Reddit always available via public fallback Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
const HANDLE_REGEX = /^[A-Za-z0-9_]{1,15}$/;
|
||||
export function normalizeHandle(input) {
|
||||
const raw = (input ?? '').trim();
|
||||
if (!raw) {
|
||||
return null;
|
||||
}
|
||||
const withoutAt = raw.startsWith('@') ? raw.slice(1) : raw;
|
||||
const handle = withoutAt.trim();
|
||||
if (!handle) {
|
||||
return null;
|
||||
}
|
||||
// X/Twitter handles are traditionally max 15 chars; keep strict to avoid surprising queries.
|
||||
if (!HANDLE_REGEX.test(handle)) {
|
||||
return null;
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
export function mentionsQueryFromUserOption(userOption) {
|
||||
if (typeof userOption === 'undefined') {
|
||||
return { query: null, error: null };
|
||||
}
|
||||
const handle = normalizeHandle(userOption);
|
||||
if (!handle) {
|
||||
return {
|
||||
query: null,
|
||||
error: 'Invalid --user handle. Expected something like @steipete (letters, digits, underscore; max 15).',
|
||||
};
|
||||
}
|
||||
return { query: `@${handle}`, error: null };
|
||||
}
|
||||
//# sourceMappingURL=normalize-handle.js.map
|
||||
Reference in New Issue
Block a user