Skip to content

Commit

Permalink
Fixed issue with unconditional MW params setters side effects
Browse files Browse the repository at this point in the history
  • Loading branch information
VadimKovalenkoSNF committed Nov 3, 2023
1 parent 407d26b commit 69654c6
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions src/MediaWiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,37 +78,51 @@ class MediaWiki {
}

set apiPath(value: string) {
this.#apiPath = value
this.initApiURLDirector()
if (value) {
this.#apiPath = value
this.initApiURLDirector()
}
}

set restApiPath(value: string) {
this.#restApiPath = value
this.initApiURLDirector()
if (value) {
this.#restApiPath = value
this.initApiURLDirector()
}
}

set domain(value: string) {
this.#domain = value
}

set wikiPath(value: string) {
this.#wikiPath = value
this.initApiURLDirector()
if (value) {
this.#wikiPath = value
this.initApiURLDirector()
}
}

set base(value: string) {
this.baseUrl = basicURLDirector.buildMediawikiBaseURL(value)
this.baseUrlDirector = new BaseURLDirector(this.baseUrl.href)
this.initMWApis()
this.initApiURLDirector()
if (value) {
this.baseUrl = basicURLDirector.buildMediawikiBaseURL(value)
this.baseUrlDirector = new BaseURLDirector(this.baseUrl.href)
this.initMWApis()
this.initApiURLDirector()
}
}

set modulePathOpt(value: string) {
this.#modulePathOpt = value
if (this.baseUrlDirector) {
this.modulePath = this.baseUrlDirector.buildModuleURL(this.#modulePathOpt)
if (value) {
this.#modulePathOpt = value
if (this.baseUrlDirector) {
this.modulePath = this.baseUrlDirector.buildModuleURL(this.#modulePathOpt)
} else {
logger.error('Base url director should be specified first')
}
} else {
logger.error('Base url director should be specified first')
if (this.baseUrlDirector) {
this.modulePath = this.baseUrlDirector.buildModuleURL(this.#modulePathOpt)
}
}
}

Expand Down

0 comments on commit 69654c6

Please sign in to comment.