mirror of
https://github.com/imputnet/cobalt.git
synced 2025-12-14 20:25:16 +00:00
api: support new xiaohongshu links, add fallbacks to getRedirectingURL
Some checks are pending
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
Run service tests / test service: ${{ matrix.service }} (push) Blocked by required conditions
Run service tests / test service functionality (push) Waiting to run
Run tests / check lockfile correctness (push) Waiting to run
Run tests / web sanity check (push) Waiting to run
Run tests / api sanity check (push) Waiting to run
Some checks are pending
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
Run service tests / test service: ${{ matrix.service }} (push) Blocked by required conditions
Run service tests / test service functionality (push) Waiting to run
Run tests / check lockfile correctness (push) Waiting to run
Run tests / web sanity check (push) Waiting to run
Run tests / api sanity check (push) Waiting to run
closes #1394 Co-authored-by: wukko <me@wukko.me>
This commit is contained in:
@@ -207,7 +207,7 @@ export const services = {
|
||||
patterns: [
|
||||
"explore/:id?xsec_token=:token",
|
||||
"discovery/item/:id?xsec_token=:token",
|
||||
"a/:shareId"
|
||||
":shareType/:shareId",
|
||||
],
|
||||
altDomains: ["xhslink.com"],
|
||||
},
|
||||
|
||||
@@ -78,7 +78,7 @@ export const testers = {
|
||||
|
||||
"xiaohongshu": pattern =>
|
||||
pattern.id?.length <= 24 && pattern.token?.length <= 64
|
||||
|| pattern.shareId?.length <= 24,
|
||||
|| pattern.shareId?.length <= 24 && pattern.shareType?.length === 1,
|
||||
|
||||
"newgrounds": pattern =>
|
||||
pattern.id?.length <= 12 || pattern.audioId?.length <= 12,
|
||||
|
||||
@@ -6,13 +6,13 @@ const https = (url) => {
|
||||
return url.replace(/^http:/i, 'https:');
|
||||
}
|
||||
|
||||
export default async function ({ id, token, shareId, h265, isAudioOnly, dispatcher }) {
|
||||
export default async function ({ id, token, shareType, shareId, h265, isAudioOnly, dispatcher }) {
|
||||
let noteId = id;
|
||||
let xsecToken = token;
|
||||
|
||||
if (!noteId) {
|
||||
const patternMatch = await resolveRedirectingURL(
|
||||
`https://xhslink.com/a/${shareId}`,
|
||||
`https://xhslink.com/${shareType}/${shareId}`,
|
||||
dispatcher
|
||||
);
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ function aliasURL(url) {
|
||||
|
||||
case "xhslink":
|
||||
if (url.hostname === 'xhslink.com' && parts.length === 3) {
|
||||
url = new URL(`https://www.xiaohongshu.com/a/${parts[2]}`);
|
||||
url = new URL(`https://www.xiaohongshu.com/${parts[1]}/${parts[2]}`);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user