@@ -43,6 +43,9 @@ const VisuallyHiddenInput = styled("input")({
43
43
width : 1 ,
44
44
} ) ;
45
45
46
+ const updateDomain = ( url : string ) =>
47
+ url . replace ( "https://www.wuxiap.com/" , "https://www.wuxiabox.com/" ) ;
48
+
46
49
const isUrlAbsolute = ( url : string ) => {
47
50
if ( url ) {
48
51
if ( url . indexOf ( "//" ) === 0 ) {
@@ -88,11 +91,7 @@ export default function Upgrade() {
88
91
const findSuitedPlugin = ( novel : OldNovelInfo ) => {
89
92
let novelSiteUrl ;
90
93
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 ) ;
96
95
} catch {
97
96
return undefined ;
98
97
}
@@ -111,7 +110,13 @@ export default function Upgrade() {
111
110
const migrateNovels = ( oldNovels : OldNovelInfo [ ] ) => {
112
111
const migratedNovels : NovelInfo [ ] = [ ] ;
113
112
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 ) {
115
120
const plugin = findSuitedPlugin ( oldNovel ) ;
116
121
let novelUrl = oldNovel . novelUrl ;
117
122
if ( plugin ) {
@@ -123,7 +128,7 @@ export default function Upgrade() {
123
128
}
124
129
migratedNovels . push ( {
125
130
id : oldNovel . novelId ,
126
- path : novelUrl ,
131
+ path : novelUrl . replace ( "//" , "/" ) ,
127
132
pluginId : plugin . id ,
128
133
name : oldNovel . novelName ,
129
134
cover : oldNovel . novelCover ,
@@ -138,7 +143,6 @@ export default function Upgrade() {
138
143
requiredPlugins . add ( plugin ) ;
139
144
}
140
145
}
141
-
142
146
setMigratedNovel ( migratedNovels ) ;
143
147
setRequiredPlugins ( Array . from ( requiredPlugins ) ) ;
144
148
} ;
0 commit comments