Skip to content

Commit 8e4a16a

Browse files
committed
add update domain for changed sites
1 parent 8c80a8c commit 8e4a16a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/routes/guides/upgrade/index.tsx

+12-8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ const VisuallyHiddenInput = styled("input")({
4343
width: 1,
4444
});
4545

46+
const updateDomain = (url: string) =>
47+
url.replace("https://www.wuxiap.com/", "https://www.wuxiabox.com/");
48+
4649
const isUrlAbsolute = (url: string) => {
4750
if (url) {
4851
if (url.indexOf("//") === 0) {
@@ -88,11 +91,7 @@ export default function Upgrade() {
8891
const findSuitedPlugin = (novel: OldNovelInfo) => {
8992
let novelSiteUrl;
9093
try {
91-
const url = novel.sourceUrl.replace(
92-
"https://www.wuxiap.com/",
93-
"https://www.wuxiabox.com/"
94-
);
95-
novelSiteUrl = new URL(url);
94+
novelSiteUrl = new URL(novel.sourceUrl);
9695
} catch {
9796
return undefined;
9897
}
@@ -111,7 +110,13 @@ export default function Upgrade() {
111110
const migrateNovels = (oldNovels: OldNovelInfo[]) => {
112111
const migratedNovels: NovelInfo[] = [];
113112
const requiredPlugins = new Set<PluginItem>();
114-
for (const oldNovel of oldNovels) {
113+
const cleanedOldNovels = oldNovels.map((novel) => ({
114+
...novel,
115+
sourceUrl: updateDomain(novel.sourceUrl),
116+
novelUrl: updateDomain(novel.novelUrl),
117+
novelCover: updateDomain(novel.novelCover || ""),
118+
}));
119+
for (const oldNovel of cleanedOldNovels) {
115120
const plugin = findSuitedPlugin(oldNovel);
116121
let novelUrl = oldNovel.novelUrl;
117122
if (plugin) {
@@ -123,7 +128,7 @@ export default function Upgrade() {
123128
}
124129
migratedNovels.push({
125130
id: oldNovel.novelId,
126-
path: novelUrl,
131+
path: novelUrl.replace("//", "/"),
127132
pluginId: plugin.id,
128133
name: oldNovel.novelName,
129134
cover: oldNovel.novelCover,
@@ -138,7 +143,6 @@ export default function Upgrade() {
138143
requiredPlugins.add(plugin);
139144
}
140145
}
141-
142146
setMigratedNovel(migratedNovels);
143147
setRequiredPlugins(Array.from(requiredPlugins));
144148
};

0 commit comments

Comments
 (0)