Compare commits
No commits in common. "a655b3b02e18a9d51246a5a56e31bb642e4c7397" and "8563addf4959e1a1bf6bfacb6fbdbedf4cd48c7c" have entirely different histories.
a655b3b02e
...
8563addf49
@ -28,6 +28,8 @@ function getDomainFromUrl(linkUrl) {
|
||||
}
|
||||
|
||||
function unshortenUrl(linkUrl) {
|
||||
console.log(linkUrl);
|
||||
|
||||
fetch("http://localhost:8000/?url=" + linkUrl)
|
||||
.then(res => {
|
||||
if (!res.ok) {
|
||||
@ -35,9 +37,7 @@ function unshortenUrl(linkUrl) {
|
||||
}
|
||||
return res.json();
|
||||
})
|
||||
.then(unshortenedUrl => {
|
||||
console.log("unshortened: " + unshortenedUrl)
|
||||
navigator.clipboard.writeText(unshortenedUrl)
|
||||
.catch(err => console.error("couldn't copy to clipboard", err));
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
});
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "Unshortener",
|
||||
"version": "0.3",
|
||||
"version": "0.2",
|
||||
|
||||
"description": "Unshorten links from Twitter.",
|
||||
|
||||
@ -17,8 +17,6 @@
|
||||
},
|
||||
|
||||
"permissions": [
|
||||
"activeTab",
|
||||
"clipboardWrite",
|
||||
"contextMenus"
|
||||
]
|
||||
}
|
||||
|
@ -9,8 +9,6 @@ UNSHORTEN = {
|
||||
't.co': unshorten_twitter
|
||||
}
|
||||
|
||||
CACHE = {}
|
||||
|
||||
app = FastAPI(docs_url=None, redoc_url=None)
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
@ -31,10 +29,4 @@ async def receive_url(url: Optional[str] = None):
|
||||
if domain not in UNSHORTEN:
|
||||
return {"error": f"cannot unshorten {domain}"}
|
||||
|
||||
if url in CACHE:
|
||||
unshortened = CACHE[url]
|
||||
else:
|
||||
unshortened = UNSHORTEN[domain](url)
|
||||
CACHE[url] = unshortened
|
||||
|
||||
return unshortened
|
||||
return UNSHORTEN[domain](url)
|
||||
|
Loading…
Reference in New Issue
Block a user