api/reddit: refactor short link resolution to use utility function

This commit is contained in:
Aholicknight 2024-12-24 13:24:48 -06:00
parent 589e96eb4a
commit 41296b7413

View file

@ -1,4 +1,5 @@
import { genericUserAgent, env } from "../../config.js";
import { getRedirectingURL } from "../../misc/utils.js";
import { getCookie, updateCookieValues } from "../cookie/manager.js";
async function getAccessToken() {
@ -48,12 +49,7 @@ async function getAccessToken() {
}
async function resolveShortLink(url) {
try {
const response = await fetch(url, { method: 'HEAD', redirect: 'manual' });
return response.headers.get('location');
} catch {
return null;
}
return await getRedirectingURL(url);
}
export default async function(obj) {