From 92374757401548e812619d9276e9144fa8fd7400 Mon Sep 17 00:00:00 2001 From: Vadim Kovalenko Date: Thu, 7 Sep 2023 12:42:48 +0300 Subject: [PATCH] Minor refactoring --- src/Downloader.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Downloader.ts b/src/Downloader.ts index 8d8cbd42..73e5cf6a 100644 --- a/src/Downloader.ts +++ b/src/Downloader.ts @@ -179,19 +179,12 @@ class Downloader { { condition: await MediaWiki.hasWikimediaDesktopRestApi(), value: MediaWiki.desktopRestApiUrl.href }, { condition: await MediaWiki.hasVisualEditorApi(), value: MediaWiki.visualEditorApiUrl.href }, ]) - - logger.log('Base Url: ', this.baseUrl) - logger.log('Base Url for Main Page: ', this.baseUrlForMainPage) - - if (!this.baseUrl || !this.baseUrlForMainPage) throw new Error('Unable to find appropriate API end-point to retrieve article HTML') } else { switch (forceRender) { case 'WikimediaDesktop': if (MediaWiki.hasWikimediaDesktopRestApi()) { this.baseUrl = MediaWiki.desktopRestApiUrl.href this.baseUrlForMainPage = MediaWiki.desktopRestApiUrl.href - logger.log('Base Url: ', this.baseUrl) - logger.log('Base Url for Main Page: ', this.baseUrlForMainPage) break } break @@ -199,9 +192,6 @@ class Downloader { if (MediaWiki.hasVisualEditorApi()) { this.baseUrl = MediaWiki.visualEditorApiUrl.href this.baseUrlForMainPage = MediaWiki.visualEditorApiUrl.href - - logger.log('Base Url: ', this.baseUrl) - logger.log('Base Url for Main Page: ', this.baseUrlForMainPage) break } break @@ -209,6 +199,10 @@ class Downloader { throw new Error('Unable to find specific API end-point to retrieve article HTML') } } + logger.log('Base Url: ', this.baseUrl) + logger.log('Base Url for Main Page: ', this.baseUrlForMainPage) + + if (!this.baseUrl || !this.baseUrlForMainPage) throw new Error('Unable to find appropriate API end-point to retrieve article HTML') } public removeEtagWeakPrefix(etag: string): string {