mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-14 17:28:27 +00:00
api/reddit: refactor short link resolution to use utility function
This commit is contained in:
parent
589e96eb4a
commit
41296b7413
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user