Cscott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/232849
Change subject: Make first parameter of setMwApi optional
......................................................................
Make first parameter of setMwApi optional
Change-Id: Ie07743e6a02c5fb66f4e83ccc944c4a56ec36bc0
---
M lib/mediawiki.ParsoidConfig.js
1 file changed, 15 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/49/232849/1
diff --git a/lib/mediawiki.ParsoidConfig.js b/lib/mediawiki.ParsoidConfig.js
index 28165d8..74637e3 100644
--- a/lib/mediawiki.ParsoidConfig.js
+++ b/lib/mediawiki.ParsoidConfig.js
@@ -97,6 +97,7 @@
this.mwApiRegexp = "";
this.timeouts = Util.clone(CONFIG_DEFAULTS.timeouts);
this.retries = Util.clone(CONFIG_DEFAULTS.retries);
+ this._uniq = 0;
if (localSettings && localSettings.setup) {
localSettings.setup(this);
@@ -414,12 +415,22 @@
*/
ParsoidConfig.prototype.setInterwiki = // Alias for backwards compat.
ParsoidConfig.prototype.setMwApi = function(prefix, apiConf) {
+ if (typeof apiConf === "undefined") {
+ apiConf = prefix; prefix = undefined;
+ }
if (typeof apiConf === 'string') {
apiConf = { uri: apiConf };
+ }
+ if (typeof prefix === 'string') {
+ apiConf.prefix = prefix;
+ }
+ if (!apiConf.prefix) {
+ apiConf.prefix = 'wiki$' + (this._uniq++);
}
if (!apiConf.domain) {
apiConf.domain = url.parse(apiConf.uri).host;
}
+ prefix = apiConf.prefix;
if (this.mwApiMap.has(prefix)) {
this.reverseMwApiMap.delete(this.mwApiMap.get(prefix).domain);
@@ -437,10 +448,13 @@
*
* Remove an mw api prefix.
*
- * @param {string} prefix
+ * @param {string|Object} prefix or api configuration object
*/
ParsoidConfig.prototype.removeInterwiki = // Alias for backwards compat.
ParsoidConfig.prototype.removeMwApi = function(prefix) {
+ if (typeof prefix === 'object') {
+ prefix = prefix.prefix;
+ }
if (!this.mwApiMap.has(prefix)) {
return;
}
--
To view, visit https://gerrit.wikimedia.org/r/232849
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie07743e6a02c5fb66f4e83ccc944c4a56ec36bc0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits