Skip to content

Commit

Permalink
Merge pull request #503 from spencermountain/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
spencermountain authored Dec 8, 2022
2 parents 87529bd + 04ce6a3 commit ad10781
Show file tree
Hide file tree
Showing 18 changed files with 175 additions and 291 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ The wikipedia api is [pretty welcoming](https://www.mediawiki.org/wiki/API:Etiqu

```js
wtf
.fetch(['Royal Cinema', 'Aldous Huxley'], 'en', {
.fetch(['Royal Cinema', 'Aldous Huxley'], {
lang: 'en',
'Api-User-Agent': '[email protected]',
})
.then((docList) => {
Expand Down
4 changes: 2 additions & 2 deletions builds/wtf_wikipedia-client.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions builds/wtf_wikipedia-client.mjs

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions builds/wtf_wikipedia.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! wtf_wikipedia 10.0.3 MIT */
/*! wtf_wikipedia 10.0.4 MIT */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('isomorphic-unfetch')) :
typeof define === 'function' && define.amd ? define(['isomorphic-unfetch'], factory) :
Expand Down Expand Up @@ -160,10 +160,10 @@
params.titles = cleanTitle(title);
} else if (title !== undefined && isArray(title) && typeof title[0] === 'number') {
//pageid array
params.pageids = title.join('|');
params.pageids = title.filter(t => t).join('|');
} else if (title !== undefined && isArray(title) === true && typeof title[0] === 'string') {
//title array
params.titles = title.map(cleanTitle).join('|');
params.titles = title.filter(t => t).map(cleanTitle).join('|');
} else {
return ''
}
Expand Down Expand Up @@ -1819,6 +1819,7 @@
}
let site = m[1] || '';
site = site.toLowerCase();
// double colon - [[m:Help:Help]]
if (site.indexOf(':') !== -1) {
let [, wiki, lang] = site.match(/^:?(.*):(.*)/);
//only allow interwikis to these specific places
Expand All @@ -1827,6 +1828,7 @@
}
obj.wiki = { wiki: wiki, lang: lang };
} else {
// [[fr:cool]]
if (wikis.hasOwnProperty(site) === false) {
return obj
}
Expand Down Expand Up @@ -2200,6 +2202,7 @@
obj.page = this.page();
} else if (obj.type === 'interwiki') {
obj.wiki = this.wiki();
obj.page = this.page();
} else {
obj.site = this.site();
}
Expand Down Expand Up @@ -3423,7 +3426,7 @@

//every value in {{tmpl|a|b|c}} needs a name
//here we come up with names for them
const hasKey = /^[\p{Letter}0-9._\- '()]+=/iu;
const hasKey = /^[\p{Letter}0-9._\- '()\t]+=/iu;

//templates with these properties are asking for trouble
const reserved = {
Expand Down Expand Up @@ -3560,7 +3563,6 @@
//remove {{}}'s and split based on pipes
tmpl = strip(tmpl || '');
let arr = pipeSplitter(tmpl);

//get template name
let name = arr.shift();

Expand Down Expand Up @@ -5932,7 +5934,8 @@
let order = ['color', 'label'];
let obj = parser(tmpl, order);
list.push(obj);
return obj.label || ' '
// return obj.label || ' '
return tmpl // keep the wiki?
},

isbn: (tmpl, list) => {
Expand Down Expand Up @@ -9423,7 +9426,7 @@
})
};

var version = '10.0.3';
var version = '10.0.4';

/**
* use the native client-side fetch function
Expand Down
17 changes: 10 additions & 7 deletions builds/wtf_wikipedia.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! wtf_wikipedia 10.0.3 MIT */
/*! wtf_wikipedia 10.0.4 MIT */
import unfetch from 'isomorphic-unfetch';

/**
Expand Down Expand Up @@ -152,10 +152,10 @@ const makeUrl = function (options, parameters = defaults$c) {
params.titles = cleanTitle(title);
} else if (title !== undefined && isArray(title) && typeof title[0] === 'number') {
//pageid array
params.pageids = title.join('|');
params.pageids = title.filter(t => t).join('|');
} else if (title !== undefined && isArray(title) === true && typeof title[0] === 'string') {
//title array
params.titles = title.map(cleanTitle).join('|');
params.titles = title.filter(t => t).map(cleanTitle).join('|');
} else {
return ''
}
Expand Down Expand Up @@ -1811,6 +1811,7 @@ const parseInterwiki = function (obj) {
}
let site = m[1] || '';
site = site.toLowerCase();
// double colon - [[m:Help:Help]]
if (site.indexOf(':') !== -1) {
let [, wiki, lang] = site.match(/^:?(.*):(.*)/);
//only allow interwikis to these specific places
Expand All @@ -1819,6 +1820,7 @@ const parseInterwiki = function (obj) {
}
obj.wiki = { wiki: wiki, lang: lang };
} else {
// [[fr:cool]]
if (wikis.hasOwnProperty(site) === false) {
return obj
}
Expand Down Expand Up @@ -2192,6 +2194,7 @@ const methods$7 = {
obj.page = this.page();
} else if (obj.type === 'interwiki') {
obj.wiki = this.wiki();
obj.page = this.page();
} else {
obj.site = this.site();
}
Expand Down Expand Up @@ -3415,7 +3418,7 @@ const pipeSplitter = function (tmpl) {

//every value in {{tmpl|a|b|c}} needs a name
//here we come up with names for them
const hasKey = /^[\p{Letter}0-9._\- '()]+=/iu;
const hasKey = /^[\p{Letter}0-9._\- '()\t]+=/iu;

//templates with these properties are asking for trouble
const reserved = {
Expand Down Expand Up @@ -3552,7 +3555,6 @@ const parser = function (tmpl, order = [], fmt) {
//remove {{}}'s and split based on pipes
tmpl = strip(tmpl || '');
let arr = pipeSplitter(tmpl);

//get template name
let name = arr.shift();

Expand Down Expand Up @@ -5924,7 +5926,8 @@ let templates$3 = {
let order = ['color', 'label'];
let obj = parser(tmpl, order);
list.push(obj);
return obj.label || ' '
// return obj.label || ' '
return tmpl // keep the wiki?
},

isbn: (tmpl, list) => {
Expand Down Expand Up @@ -9415,7 +9418,7 @@ const fetch = function (title, options, callback) {
})
};

var version = '10.0.3';
var version = '10.0.4';

/**
* use the native client-side fetch function
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
#### [unreleased ]
-->
#### 10.0.4 [Dec 2022]
- **[fix]** - mangled interwiki link #502
- **[fix]** - tabs in infoboxes #435
- **[update]** - dependencies


#### 10.0.3 [Oct 2022]
- **[fix]** - improved i18n infobox classification
- **[update]** - dependencies
Expand Down
Loading

0 comments on commit ad10781

Please sign in to comment.