Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
VadimKovalenkoSNF committed Sep 7, 2023
1 parent c6fa28b commit 9237475
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/Downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,36 +179,30 @@ 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
case 'VisualEditor':

Check warning on line 191 in src/Downloader.ts

View check run for this annotation

Codecov / codecov/patch

src/Downloader.ts#L190-L191

Added lines #L190 - L191 were not covered by tests
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

Check warning on line 195 in src/Downloader.ts

View check run for this annotation

Codecov / codecov/patch

src/Downloader.ts#L193-L195

Added lines #L193 - L195 were not covered by tests
}
break
default:
throw new Error('Unable to find specific API end-point to retrieve article HTML')

Check warning on line 199 in src/Downloader.ts

View check run for this annotation

Codecov / codecov/patch

src/Downloader.ts#L197-L199

Added lines #L197 - L199 were not covered by tests
}
}
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 {
Expand Down

0 comments on commit 9237475

Please sign in to comment.