Skip to content

Commit c2ea471

Browse files
Merge pull request #556 from spencermountain/dev
Dev
2 parents d9ba589 + 7311361 commit c2ea471

File tree

10 files changed

+64
-25
lines changed

10 files changed

+64
-25
lines changed

builds/wtf_wikipedia-client.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

builds/wtf_wikipedia-client.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

builds/wtf_wikipedia.cjs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,18 @@
179179
* @returns {*} result
180180
*/
181181
const getResult = function (data, options = {}) {
182+
// handle nothing found or no data passed
183+
if(!data?.query?.pages || !data?.query || !data){
184+
return null
185+
}
186+
182187
//get all the pagesIds from the result
183188
let pages = Object.keys(data.query.pages);
184189

185190
// map over the pageIds to parse out all the information
186191
return pages.map((id) => {
187192
// get the page by pageID
193+
188194
let page = data.query.pages[id] || {};
189195

190196
// if the page is missing or not found than return null
@@ -1982,13 +1988,14 @@
19821988
'source',
19831989
'syntaxhighlight',
19841990
'timeline',
1991+
'maplink',
19851992
];
19861993
const openTag = `< ?(${ignore$1.join('|')}) ?[^>]{0,200}?>`;
19871994
const closeTag = `< ?/ ?(${ignore$1.join('|')}) ?>`;
19881995
const anyChar = '\\s\\S'; //including newline
19891996
const noThanks = new RegExp(`${openTag}[${anyChar}]+?${closeTag}`, 'gi');
19901997

1991-
const kill_xml = function (wiki) {
1998+
const kill_xml = function(wiki) {
19921999
//(<ref> tags are parsed in Section class) - luckily, refs can't be recursive.
19932000
//types of html/xml that we want to trash completely.
19942001
wiki = wiki.replace(noThanks, ' ');
@@ -10513,7 +10520,7 @@
1051310520
})
1051410521
};
1051510522

10516-
var version = '10.1.6';
10523+
var version = '10.1.7';
1051710524

1051810525
/**
1051910526
* use the native client-side fetch function

builds/wtf_wikipedia.mjs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,18 @@ const makeUrl = function (options, parameters = defaults$c) {
175175
* @returns {*} result
176176
*/
177177
const getResult = function (data, options = {}) {
178+
// handle nothing found or no data passed
179+
if(!data?.query?.pages || !data?.query || !data){
180+
return null
181+
}
182+
178183
//get all the pagesIds from the result
179184
let pages = Object.keys(data.query.pages);
180185

181186
// map over the pageIds to parse out all the information
182187
return pages.map((id) => {
183188
// get the page by pageID
189+
184190
let page = data.query.pages[id] || {};
185191

186192
// if the page is missing or not found than return null
@@ -1978,13 +1984,14 @@ const ignore$1 = [
19781984
'source',
19791985
'syntaxhighlight',
19801986
'timeline',
1987+
'maplink',
19811988
];
19821989
const openTag = `< ?(${ignore$1.join('|')}) ?[^>]{0,200}?>`;
19831990
const closeTag = `< ?/ ?(${ignore$1.join('|')}) ?>`;
19841991
const anyChar = '\\s\\S'; //including newline
19851992
const noThanks = new RegExp(`${openTag}[${anyChar}]+?${closeTag}`, 'gi');
19861993

1987-
const kill_xml = function (wiki) {
1994+
const kill_xml = function(wiki) {
19881995
//(<ref> tags are parsed in Section class) - luckily, refs can't be recursive.
19891996
//types of html/xml that we want to trash completely.
19901997
wiki = wiki.replace(noThanks, ' ');
@@ -10509,7 +10516,7 @@ const fetch = function (title, options, callback) {
1050910516
})
1051010517
};
1051110518

10512-
var version = '10.1.6';
10519+
var version = '10.1.7';
1051310520

1051410521
/**
1051510522
* use the native client-side fetch function

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
55
-->
66

7+
#### 10.1.7 [Sep 2023]
8+
- **[fix]** - don't crash on huge geojson blob #555
9+
710
#### 10.1.6 [Sep 2023]
811

912
- **[change]** - handle fetch data errors

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "wtf_wikipedia",
33
"description": "parse wikiscript into json",
4-
"version": "10.1.6",
4+
"version": "10.1.7",
55
"main": "src/index.js",
66
"module": "builds/wtf_wikipedia.mjs",
77
"unpkg": "builds/wtf_wikipedia-client.min.js",

scratch.js

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
11
import wtf from './src/index.js'
2-
import plg from './plugins/i18n/src/index.js'
3-
wtf.plugin(plg)
2+
console.log('start')
43

5-
let str = `#AANSTUUR[[Xai-Xai]]
6-
`
7-
// let str = ` {{font|text=也可以只選用其中一項選項。|size=25px}} `
8-
let doc = wtf(str)
9-
console.log(doc.text())
10-
// doc.templates().map((s) => s.json())
11-
// console.log(doc.templates()[4].json())
4+
let str = `hello
5+
{{usableitinerary}}
6+
{{PartOfItinerary|North America itineraries}}
7+
<maplink text="" zoom="5" group="route1" class="no-icon">
128
9+
{
10+
"type": "FeatureCollection",
11+
"features": [
12+
{
13+
"type": "Feature",
14+
"properties": {},
15+
"geometry": {
16+
"type": "LineString",
17+
"coordinates": [
18+
[
19+
-117.02964,
20+
32.54259
21+
],
22+
[
23+
-117.03059,
24+
32.54305
25+
]
1326
14-
// let doc = await wtf.fetch("Space_disco", "it")
15-
// console.log(doc.text())
16-
// trunc
17-
// wtf.fetch("2007 FIFA Women's World Cup Group A", "en")
27+
]
28+
}
29+
}
30+
]
31+
}
1832
19-
// fails on percentage template
20-
// wtf.fetch("Sacramento Mountain Lions", "es")
33+
</maplink>
34+
`
35+
// let doc = wtf(str)
36+
const doc = await wtf.fetch('https://en.wikivoyage.org/wiki/Interstate_5');
2137

22-
// fails on min template
23-
// wtf.fetch("Phase finale du Championnat du monde masculin de handball 2019", "fr")
38+
console.log(doc.text());

src/01-document/preProcess/kill_xml.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const ignore = [
1717
'source',
1818
'syntaxhighlight',
1919
'timeline',
20+
'maplink',
2021
]
2122
const openTag = `< ?(${ignore.join('|')}) ?[^>]{0,200}?>`
2223
const closeTag = `< ?/ ?(${ignore.join('|')}) ?>`

src/_fetch/getResult.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@
99
* @returns {*} result
1010
*/
1111
const getResult = function (data, options = {}) {
12+
// handle nothing found or no data passed
13+
if(!data?.query?.pages || !data?.query || !data){
14+
return null
15+
}
16+
1217
//get all the pagesIds from the result
1318
let pages = Object.keys(data.query.pages)
1419

1520
// map over the pageIds to parse out all the information
1621
return pages.map((id) => {
1722
// get the page by pageID
23+
1824
let page = data.query.pages[id] || {}
1925

2026
// if the page is missing or not found than return null

src/_version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default '10.1.6'
1+
export default '10.1.7'

0 commit comments

Comments
 (0)