mirror of
https://github.com/wukko/cobalt.git
synced 2025-01-27 21:26:18 +01:00
api/reddit: refactor short link resolution to use utility function
This commit is contained in:
parent
589e96eb4a
commit
41296b7413
1 changed files with 2 additions and 6 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue