From 8da330e0e30029519694f215d60e1422da352e03 Mon Sep 17 00:00:00 2001 From: Valyukhov Date: Wed, 9 Apr 2025 09:13:39 +0300 Subject: [PATCH] fix: :bug: fix wrong auth --- components/Project/Download.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/components/Project/Download.js b/components/Project/Download.js index ed052269..dced5861 100644 --- a/components/Project/Download.js +++ b/components/Project/Download.js @@ -208,15 +208,24 @@ function Download({ : t('books:' + bookCode), }, ] + const reformatLink = (link) => { + if (link.includes('commit')) { + const newLink = link.replace(/commit\/[a-f0-9]+/, 'branch/master') + return newLink + } + + return link + } const createChapters = async (bookLink, typeProject) => { if (!bookLink) return null + const reformatedBookLink = reformatLink(bookLink) let chapterVerse = {} if (typeProject === 'obs') { chapterVerse = obsStoryVerses } else { const { data: jsonChapterVerse, error: errorJsonChapterVerse } = await getCountChaptersAndVerses({ - link: bookLink, + link: reformatedBookLink, }) chapterVerse = jsonChapterVerse if (errorJsonChapterVerse) { @@ -266,9 +275,13 @@ function Download({ } const { owner, repo, commit, manifest } = resources[resource] const bookPath = manifest.projects.find((el) => el.identifier === bookCode)?.path + // const url = ` ${ + // process.env.NEXT_PUBLIC_NODE_HOST ?? 'https://git.door43.org' + // }/${owner}/${repo}/raw/commit/${commit}/${bookPath.replace(/^\.\//, '')}` + // urls[resource] = url const url = ` ${ process.env.NEXT_PUBLIC_NODE_HOST ?? 'https://git.door43.org' - }/${owner}/${repo}/raw/commit/${commit}/${bookPath.replace(/^\.\//, '')}` + }/${owner}/${repo}/raw/branch/master/${bookPath.replace(/^\.\//, '')}` urls[resource] = url } } @@ -358,7 +371,7 @@ function Download({ acc[chapter] = 0 return acc }, {}) - const methods = await gitDoorAxios.get('/api/methods') + const methods = await axios.get('/api/methods') const method = methods.data.find((method) => method.title === project.method) if (!method?.offline_steps) { return null @@ -426,7 +439,7 @@ function Download({ }) zip.file('obs-images-360px.zip', obsImagesZipContent) } else { - const response = await axios.get(url) + const response = await gitDoorAxios.get(url) if (response.status === 200) { const content = response.data zip.file(`${resource}.${url.split('.').pop()}`, content)