Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getArticle not working with special characters in title #141

Open
Juul opened this issue Dec 2, 2017 · 4 comments
Open

getArticle not working with special characters in title #141

Juul opened this issue Dec 2, 2017 · 4 comments

Comments

@Juul
Copy link
Contributor

Juul commented Dec 2, 2017

The program below works for en.wikipedia.org but for openwetware.org it outputs "Got: undefined" and this is the actual response returned from the server:

{"warnings":{"main":{"*":"Unrecognized parameter: rand."}},"batchcomplete":"","query":{"pages":{"-1":{"title":"Main%20Page","invalidreason":"The requested page title contains invalid characters: \"%20\".","invalid":""}}}}
#!/usr/bin/env node

var mw = require('nodemw');

var client = new mw({
  protocol: "https",
  server: "openwetware.org",
  path: "/w",
  debug: true
});

client.getArticle("Main Page", function(err, data) {
  if(err) {
    console.error(err);
    process.exit(1);
  }

  console.log("Got:", data);
});
@macbre
Copy link
Owner

macbre commented Dec 2, 2017

I believe you have to replace spaces in the title with underscores.

@Juul
Copy link
Contributor Author

Juul commented Dec 5, 2017

It works with spaces. I believe this pull request solves my problems.

@macbre
Copy link
Owner

macbre commented Dec 5, 2017

But it does not work for me (with your fix applied) :)

info:    nodemw v0.12.0 (node.js v6.12.0; linux x64)

@Juul
Copy link
Contributor Author

Juul commented Dec 5, 2017

Ah yes there was another problem. The openwetware.org mediawiki installation has a different script path so the path option had to be set to "/mediawiki".

The script path on a given wiki installation is available via the Special:Version page. It would be really cool if nodemw could auto-detect the script path given e.g. a URL to an arbitrary page on the wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants