mirror of
https://github.com/zedeus/nitter.git
synced 2026-01-28 14:22:48 -05:00
Add t.co and /cards link resolvers
For t.co links: https://t.co/.. -> nitter.net/t.co/.. For card links: https://cards.twitter.com/cards/.. -> nitter.net/cards/...
This commit is contained in:
13
src/api/resolver.nim
Normal file
13
src/api/resolver.nim
Normal file
@@ -0,0 +1,13 @@
|
||||
import asyncdispatch, httpclient
|
||||
|
||||
import ".."/[formatters, types]
|
||||
|
||||
proc resolve*(url: string; prefs: Prefs): Future[string] {.async.} =
|
||||
let client = newAsyncHttpClient(maxRedirects=0)
|
||||
try:
|
||||
let resp = await client.request(url, $HttpHead)
|
||||
result = resp.headers["location"].replaceUrl(prefs)
|
||||
except:
|
||||
discard
|
||||
finally:
|
||||
client.close()
|
||||
Reference in New Issue
Block a user