Cscott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/232840
Change subject: Allow configuration of the "domain" separate from the MW API URL
......................................................................
Allow configuration of the "domain" separate from the MW API URL
This prevents functionality regression compared to the v1 API.
Change-Id: Idcc969d7c27e850b54707b4aadc8447b6ec9d98e
---
M api/routes.js
M lib/mediawiki.ParsoidConfig.js
2 files changed, 8 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid
refs/changes/40/232840/1
diff --git a/api/routes.js b/api/routes.js
index d512b2f..09d8178 100644
--- a/api/routes.js
+++ b/api/routes.js
@@ -47,7 +47,7 @@
var iwp = parsoidConfig.reverseMwApiMap.get(req.params.domain);
if (!iwp) {
- return errOut('Invalid domain.');
+ return errOut('Invalid domain: '+req.params.domain);
}
res.local('iwp', iwp);
diff --git a/lib/mediawiki.ParsoidConfig.js b/lib/mediawiki.ParsoidConfig.js
index 4652052..28165d8 100644
--- a/lib/mediawiki.ParsoidConfig.js
+++ b/lib/mediawiki.ParsoidConfig.js
@@ -417,12 +417,15 @@
if (typeof apiConf === 'string') {
apiConf = { uri: apiConf };
}
+ if (!apiConf.domain) {
+ apiConf.domain = url.parse(apiConf.uri).host;
+ }
if (this.mwApiMap.has(prefix)) {
-
this.reverseMwApiMap.delete(url.parse(this.mwApiMap.get(prefix).uri).host);
+ this.reverseMwApiMap.delete(this.mwApiMap.get(prefix).domain);
}
this.mwApiMap.set(prefix, apiConf);
- this.reverseMwApiMap.set(url.parse(apiConf.uri).host, prefix);
+ this.reverseMwApiMap.set(apiConf.domain, prefix);
if (this.mwApiRegexp.match('(^|\\|)' + prefix + '(\\||$)') === null) {
this.mwApiRegexp += (this.mwApiRegexp ? '|' : '') + prefix;
@@ -441,8 +444,8 @@
if (!this.mwApiMap.has(prefix)) {
return;
}
- var u = url.parse(this.mwApiMap.get(prefix).uri);
- this.reverseMwApiMap.delete(u.host);
+ var domain = this.mwApiMap.get(prefix).domain;
+ this.reverseMwApiMap.delete(domain);
this.mwApiMap.delete(prefix);
this.mwApiRegexp = this.mwApiRegexp.replace(
new RegExp('(^|\\|)' + prefix + '(\\||$)'), function() {
--
To view, visit https://gerrit.wikimedia.org/r/232840
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idcc969d7c27e850b54707b4aadc8447b6ec9d98e
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