Skip to content

Commit

Permalink
Merge pull request #100 from wikimedia/test-dot-local
Browse files Browse the repository at this point in the history
Unify the .test.local uri massaging in web.js
  • Loading branch information
earldouglas committed Dec 31, 2014
2 parents c075063 + ac96275 commit 044a225
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
9 changes: 1 addition & 8 deletions lib/filters/global/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@ module.exports = {

var rp = req.params;

// TODO: this is a hack to allow us to test with a safe/fake
// domain, but still call out to a real service
var domain = rp.domain;
if (domain === 'en.wikipedia.test.local') {
domain = 'en.wikipedia.org';
}

req.uri = 'http://' + domain + '/w/api.php';
req.uri = 'http://' + rp.domain + '/w/api.php';
var body = req.body || req.query;
body.action = 'query';
// Always request json
Expand Down
3 changes: 0 additions & 3 deletions lib/filters/global/parsoid.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ var contentTypes = {
function pagebundle(parsoidHost, restbase, domain, key, rev) {
// TODO: this is a hack to allow us to test with a safe/fake domain, but
// still call out to a real service
if (domain === 'en.wikipedia.test.local') {
domain = 'en.wikipedia.org';
}
var uri = parsoidHost + '/v2/' + domain + '/' + key + '/pagebundle/' + rev;
return restbase.get({ uri: uri });
}
Expand Down
9 changes: 9 additions & 0 deletions lib/filters/global/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
var preq = require('preq');

function handleAll (restbase, req) {

// some tests use a fake en.wikipedia.test.local domain, which will confuse
// external services such as parsoid and api.php -- if found here, replace
// with en.wikipedia.org
req.uri = req.uri.replace(/^http:\/\/en\.wikipedia\.test\.local\//,
'http://en.wikipedia.org/')
.replace(/^http:\/\/parsoid-lb\.eqiad\.wikimedia\.org\/v2\/en\.wikipedia\.test\.local\//,
'http://parsoid-lb.eqiad.wikimedia.org/v2/en.wikipedia.org/');

if (restbase._options.conf.offline) {
throw new Error("We are offline, you are tring to fallback to dynamic api");
}
Expand Down

0 comments on commit 044a225

Please sign in to comment.