-
Notifications
You must be signed in to change notification settings - Fork 129
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
URL of the final wikipage #260
Comments
hey lawrence, no there isn't a clean one. Maybe there should be. let title=doc.title().replace(/ /g,'_')
title=encodeURIComponent(title)
let url=`${lang}.wikipedia.org/wiki/${title}}` we need to store the language for the upcoming image url refactor, so maybe we should add this in after that. |
When you pull from an other wiki domain - e.g. Wikiversity
/* FILE: /src/_fetch/_title2url
function that converts a title from domain Wikipedia, Wikiversity, .... and
a specific language "lang" and a domain "wikipedia", "wikiversity" into
an URL that displays the source e.g.
https://en.wikiversity.org/wiki/Swarm_intelligence
default language is: "en"
default domain is: "wikipedia"
*/
const title2url = function( title, lang, domain ) {
// set default values for parameters
title = title || "Main Page";
domain = domain || "wikipedia";
lang = lang || "en";
// replace blank to underscore
title=title.replace(/ /g,'_');
title = encodeURIComponent(title);
let url=`https://${lang}.${domain}.org/wiki/${title}}`
return url;
};
module.exports =title2url; Maybe Spencer could provide the function as file in cheers, |
added |
Can you ping this thread once 497e075 makes it into |
sure |
released as |
Works like a charm, thanks! |
I spoke too soon, I'm seeing a small issue where the final url from
I can look into this if you want, should be reproducible with the following script but note that I'm seeing it for every const doc = await wtf.fetch('Nuclear Waste Technical Review Board')
console.log(doc.url()) |
ah, good eye. |
fixed in |
Was going through the API, is there a current way to generate a link to the wiki URL that the info is being pulled from.
The text was updated successfully, but these errors were encountered: