@@ -208,15 +208,24 @@ function Download({
208208 : t ( 'books:' + bookCode ) ,
209209 } ,
210210 ]
211+ const reformatLink = ( link ) => {
212+ if ( link . includes ( 'commit' ) ) {
213+ const newLink = link . replace ( / c o m m i t \/ [ a - f 0 - 9 ] + / , 'branch/master' )
214+ return newLink
215+ }
216+
217+ return link
218+ }
211219 const createChapters = async ( bookLink , typeProject ) => {
212220 if ( ! bookLink ) return null
221+ const reformatedBookLink = reformatLink ( bookLink )
213222 let chapterVerse = { }
214223 if ( typeProject === 'obs' ) {
215224 chapterVerse = obsStoryVerses
216225 } else {
217226 const { data : jsonChapterVerse , error : errorJsonChapterVerse } =
218227 await getCountChaptersAndVerses ( {
219- link : bookLink ,
228+ link : reformatedBookLink ,
220229 } )
221230 chapterVerse = jsonChapterVerse
222231 if ( errorJsonChapterVerse ) {
@@ -266,9 +275,13 @@ function Download({
266275 }
267276 const { owner, repo, commit, manifest } = resources [ resource ]
268277 const bookPath = manifest . projects . find ( ( el ) => el . identifier === bookCode ) ?. path
278+ // const url = ` ${
279+ // process.env.NEXT_PUBLIC_NODE_HOST ?? 'https://git.door43.org'
280+ // }/${owner}/${repo}/raw/commit/${commit}/${bookPath.replace(/^\.\//, '')}`
281+ // urls[resource] = url
269282 const url = ` ${
270283 process . env . NEXT_PUBLIC_NODE_HOST ?? 'https://git.door43.org'
271- } /${ owner } /${ repo } /raw/commit/ ${ commit } /${ bookPath . replace ( / ^ \. \/ / , '' ) } `
284+ } /${ owner } /${ repo } /raw/branch/master /${ bookPath . replace ( / ^ \. \/ / , '' ) } `
272285 urls [ resource ] = url
273286 }
274287 }
@@ -358,7 +371,7 @@ function Download({
358371 acc [ chapter ] = 0
359372 return acc
360373 } , { } )
361- const methods = await gitDoorAxios . get ( '/api/methods' )
374+ const methods = await axios . get ( '/api/methods' )
362375 const method = methods . data . find ( ( method ) => method . title === project . method )
363376 if ( ! method ?. offline_steps ) {
364377 return null
@@ -426,7 +439,7 @@ function Download({
426439 } )
427440 zip . file ( 'obs-images-360px.zip' , obsImagesZipContent )
428441 } else {
429- const response = await axios . get ( url )
442+ const response = await gitDoorAxios . get ( url )
430443 if ( response . status === 200 ) {
431444 const content = response . data
432445 zip . file ( `${ resource } .${ url . split ( '.' ) . pop ( ) } ` , content )
0 commit comments