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