Compare commits

..

No commits in common. "a655b3b02e18a9d51246a5a56e31bb642e4c7397" and "8563addf4959e1a1bf6bfacb6fbdbedf4cd48c7c" have entirely different histories.

3 changed files with 6 additions and 16 deletions

View File

@ -28,6 +28,8 @@ function getDomainFromUrl(linkUrl) {
} }
function unshortenUrl(linkUrl) { function unshortenUrl(linkUrl) {
console.log(linkUrl);
fetch("http://localhost:8000/?url=" + linkUrl) fetch("http://localhost:8000/?url=" + linkUrl)
.then(res => { .then(res => {
if (!res.ok) { if (!res.ok) {
@ -35,9 +37,7 @@ function unshortenUrl(linkUrl) {
} }
return res.json(); return res.json();
}) })
.then(unshortenedUrl => { .then(data => {
console.log("unshortened: " + unshortenedUrl) console.log(data);
navigator.clipboard.writeText(unshortenedUrl)
.catch(err => console.error("couldn't copy to clipboard", err));
}); });
} }

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "Unshortener", "name": "Unshortener",
"version": "0.3", "version": "0.2",
"description": "Unshorten links from Twitter.", "description": "Unshorten links from Twitter.",
@ -17,8 +17,6 @@
}, },
"permissions": [ "permissions": [
"activeTab",
"clipboardWrite",
"contextMenus" "contextMenus"
] ]
} }

View File

@ -9,8 +9,6 @@ UNSHORTEN = {
't.co': unshorten_twitter 't.co': unshorten_twitter
} }
CACHE = {}
app = FastAPI(docs_url=None, redoc_url=None) app = FastAPI(docs_url=None, redoc_url=None)
app.add_middleware( app.add_middleware(
CORSMiddleware, CORSMiddleware,
@ -31,10 +29,4 @@ async def receive_url(url: Optional[str] = None):
if domain not in UNSHORTEN: if domain not in UNSHORTEN:
return {"error": f"cannot unshorten {domain}"} return {"error": f"cannot unshorten {domain}"}
if url in CACHE: return UNSHORTEN[domain](url)
unshortened = CACHE[url]
else:
unshortened = UNSHORTEN[domain](url)
CACHE[url] = unshortened
return unshortened