mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🐛 完善帖子链接处理
This commit is contained in:
@@ -14,7 +14,7 @@ import { createPost } from "./TGWindow.js";
|
||||
|
||||
/**
|
||||
* @function parsePost
|
||||
* @since Beta v0.3.8
|
||||
* @since Beta v0.5.5
|
||||
* @description 处理帖子
|
||||
* @param {string} link
|
||||
* @returns {Promise<false|string>} - 处理情况,或者转换后的链接
|
||||
@@ -40,11 +40,15 @@ export async function parsePost(link: string): Promise<false | string> {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (url.hostname === "bbs.mihoyo.com" || url.hostname === "www.miyoushe.com") {
|
||||
if (url.hostname.endsWith(".mihoyo.com") || url.hostname.endsWith(".miyoushe.com")) {
|
||||
if (url.pathname.includes("/article/")) {
|
||||
const postId = url.pathname.split("/").pop();
|
||||
if (typeof postId !== "string") return false;
|
||||
return postId;
|
||||
} else if (url.hash.startsWith("#/article/")) {
|
||||
const postId = url.hash.split("/").pop();
|
||||
if (typeof postId !== "string") return false;
|
||||
return postId;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user