mirror of
https://github.com/thegeneralist01/archivr
synced 2026-07-22 03:05:32 +02:00
feat: server-side t.co resolver + frontend augmentation
Server (routes.rs): POST /api/util/resolve-tco — unauthenticated, accepts JSON array of https://t.co/<alphanumeric> URLs only (strict regex validation, no SSRF via input), capped at 50 per batch, 3 s timeout, redirect(Policy::none) so the server only ever touches t.co itself. HEAD first, GET fallback if HEAD returns no Location. Location sanitized to http/https only — javascript:/data:/etc. fall back to the original t.co. api.js: resolveTcoUrls(urls) — project-convention wrapper for the new endpoint. Returns {} on failure (callers degrade gracefully to bare t.co links). TweetPreview.jsx: After tweet data loads, per-tweet range-based coverage detection: builds covered [start,end) from existing entity fromIndex/toIndex or indices fallback, then finds regex matches whose span is NOT covered. Resolves unique uncovered t.co URLs via resolveTcoUrls(), synthesises one entity per occurrence (with exact fromIndex/toIndex so normalizeUrlAnn gets correct bounds even for duplicate t.co URLs in the same tweet). Augments entities.urls before setTweets() so all rendering paths see expanded URLs.
This commit is contained in:
parent
a06c541605
commit
1589eb68b5
9 changed files with 185 additions and 50 deletions
BIN
vendor/twitter/__pycache__/scrape_user_tweet_contents.cpython-313.pyc
vendored
Normal file
BIN
vendor/twitter/__pycache__/scrape_user_tweet_contents.cpython-313.pyc
vendored
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue