mirror of
https://github.com/wukko/cobalt.git
synced 2025-04-30 22:44:24 +02:00
api/tiktok: normalize short link URL & catch empty patternMatch
This commit is contained in:
parent
2f38260e23
commit
ab13f78326
@ -1,6 +1,6 @@
|
|||||||
import Cookie from "../cookie/cookie.js";
|
import Cookie from "../cookie/cookie.js";
|
||||||
|
|
||||||
import { extract } from "../url.js";
|
import { extract, normalizeURL } from "../url.js";
|
||||||
import { genericUserAgent } from "../../config.js";
|
import { genericUserAgent } from "../../config.js";
|
||||||
import { updateCookie } from "../cookie/manager.js";
|
import { updateCookie } from "../cookie/manager.js";
|
||||||
import { createStream } from "../../stream/manage.js";
|
import { createStream } from "../../stream/manage.js";
|
||||||
@ -23,8 +23,8 @@ export default async function(obj) {
|
|||||||
|
|
||||||
if (html.startsWith('<a href="https://')) {
|
if (html.startsWith('<a href="https://')) {
|
||||||
const extractedURL = html.split('<a href="')[1].split('?')[0];
|
const extractedURL = html.split('<a href="')[1].split('?')[0];
|
||||||
const { patternMatch } = extract(extractedURL);
|
const { patternMatch } = extract(normalizeURL(extractedURL));
|
||||||
postId = patternMatch.postId;
|
postId = patternMatch?.postId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!postId) return { error: "fetch.short_link" };
|
if (!postId) return { error: "fetch.short_link" };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user