mediawiki-projects-list 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -1
- package/index.js +13 -11
- package/package.json +1 -1
- package/projects.json +16 -16
package/index.d.ts
CHANGED
|
@@ -80,7 +80,7 @@ declare module 'mediawiki-projects-list' {
|
|
|
80
80
|
|
|
81
81
|
export function idStringToUrl(idString: string, projectName: string): URL | null;
|
|
82
82
|
|
|
83
|
-
export function
|
|
83
|
+
export function inputToFrontendProxy(input: string): {
|
|
84
84
|
fullNamePath: string;
|
|
85
85
|
fullArticlePath: string;
|
|
86
86
|
fullScriptPath: string;
|
package/index.js
CHANGED
|
@@ -127,12 +127,14 @@ function inputToWikiProject(input) {
|
|
|
127
127
|
function urlToIdString(url) {
|
|
128
128
|
if ( functionCache.urlToIdString.has(url.href) ) return functionCache.urlToIdString.get(url.href);
|
|
129
129
|
let result = null;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
/** @type {WikiProject|FrontendProxy|undefined} */
|
|
131
|
+
let project = wikiProjects.find( wikiProject => wikiProject.idString && url.hostname.endsWith( wikiProject.name ) );
|
|
132
|
+
if ( !project ) project = frontendProxies.find( frontendProxy => frontendProxy.idString && url.hostname.endsWith( frontendProxy.name ) );
|
|
133
|
+
if ( project ) {
|
|
134
|
+
let regex = url.href.match( new RegExp( project.regex ) )?.slice(2);
|
|
133
135
|
if ( regex?.length ) {
|
|
134
|
-
if (
|
|
135
|
-
result = regex.join(
|
|
136
|
+
if ( project.idString.direction === 'desc' ) regex.reverse();
|
|
137
|
+
result = regex.join(project.idString.separator);
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
140
|
functionCache.urlToIdString.set(url.href, result);
|
|
@@ -152,12 +154,12 @@ function idStringToUrl(idString, projectName) {
|
|
|
152
154
|
return ( result ? new URL(result) : result );
|
|
153
155
|
}
|
|
154
156
|
let result = null;
|
|
155
|
-
let
|
|
156
|
-
if ( !
|
|
157
|
-
if (
|
|
158
|
-
let regex = idString.match( new RegExp( '^' +
|
|
159
|
-
if ( regex && regex.length <=
|
|
160
|
-
result =
|
|
157
|
+
let project = wikiProjects.find( wikiProject => wikiProject.idString && wikiProject.name === projectName )?.idString;
|
|
158
|
+
if ( !project ) project = frontendProxies.find( frontendProxy => frontendProxy.idString && frontendProxy.name === projectName )?.idString;
|
|
159
|
+
if ( project ) {
|
|
160
|
+
let regex = idString.match( new RegExp( '^' + project.regex + '$' ) )?.[1].split(project.separator);
|
|
161
|
+
if ( regex && regex.length <= project.scriptPaths.length ) {
|
|
162
|
+
result = project.scriptPaths[regex.length - 1].replace( /\$(\d)/g, (match, n) => regex[n - 1] );
|
|
161
163
|
}
|
|
162
164
|
}
|
|
163
165
|
functionCache.idStringToUrl.set(cacheKey, result);
|
package/package.json
CHANGED
package/projects.json
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
"frontendProxies": [
|
|
4
4
|
{
|
|
5
5
|
"name": "wikiless.org",
|
|
6
|
-
"regex": "wikiless\\.org/.*?\\?(?:.*?&)?lang=([a-z\\d-]{1,50})(?:&|/?$)",
|
|
7
|
-
"namePath": "https://wikiless.org/?lang=$
|
|
8
|
-
"articlePath": "https://wikiless.org/wiki/?lang=$
|
|
9
|
-
"scriptPath": "https://$
|
|
6
|
+
"regex": "(wikiless\\.org/.*?\\?(?:.*?&)?lang=([a-z\\d-]{1,50}))(?:&|/?$)",
|
|
7
|
+
"namePath": "https://wikiless.org/?lang=$2",
|
|
8
|
+
"articlePath": "https://wikiless.org/wiki/?lang=$2",
|
|
9
|
+
"scriptPath": "https://$2.wikipedia.org/w/",
|
|
10
10
|
"idString": {
|
|
11
11
|
"regex": "([a-z\\d-]{1,50})",
|
|
12
12
|
"scriptPaths": [
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"name": "wikiwand.com",
|
|
19
|
-
"regex": "(?:www\\.)?wikiwand\\.com/([a-z\\d-]{1,50})/?",
|
|
20
|
-
"namePath": "https://www.wikiwand.com/$
|
|
21
|
-
"articlePath": "https://www.wikiwand.com/$
|
|
22
|
-
"scriptPath": "https://$
|
|
19
|
+
"regex": "((?:www\\.)?wikiwand\\.com/([a-z\\d-]{1,50}))/?",
|
|
20
|
+
"namePath": "https://www.wikiwand.com/$2/",
|
|
21
|
+
"articlePath": "https://www.wikiwand.com/$2/",
|
|
22
|
+
"scriptPath": "https://$2.wikipedia.org/w/",
|
|
23
23
|
"relativeFix": "^/wiki(?=/)",
|
|
24
24
|
"idString": {
|
|
25
25
|
"regex": "([a-z\\d-]{1,50})",
|
|
@@ -30,18 +30,18 @@
|
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
"name": "breezewiki.com",
|
|
33
|
-
"regex": "breezewiki\\.com/([a-z\\d-]{1,50})(?:/wiki/|/?$)",
|
|
34
|
-
"namePath": "https://breezewiki.com/$
|
|
35
|
-
"articlePath": "https://breezewiki.com/$
|
|
36
|
-
"scriptPath": "https://$
|
|
33
|
+
"regex": "(breezewiki\\.com/([a-z\\d-]{1,50}))(?:/wiki/|/?$)",
|
|
34
|
+
"namePath": "https://breezewiki.com/$2/",
|
|
35
|
+
"articlePath": "https://breezewiki.com/$2/wiki/",
|
|
36
|
+
"scriptPath": "https://$2.fandom.com/",
|
|
37
37
|
"note": "Missing language support."
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
"name": "breezewiki.pussthecat.org",
|
|
41
|
-
"regex": "breezewiki\\.pussthecat\\.org/([a-z\\d-]{1,50})(?:/wiki/|/?$)",
|
|
42
|
-
"namePath": "https://breezewiki.pussthecat.org/$
|
|
43
|
-
"articlePath": "https://breezewiki.pussthecat.org/$
|
|
44
|
-
"scriptPath": "https://$
|
|
41
|
+
"regex": "(breezewiki\\.pussthecat\\.org/([a-z\\d-]{1,50}))(?:/wiki/|/?$)",
|
|
42
|
+
"namePath": "https://breezewiki.pussthecat.org/$2/",
|
|
43
|
+
"articlePath": "https://breezewiki.pussthecat.org/$2/wiki/",
|
|
44
|
+
"scriptPath": "https://$2.fandom.com/",
|
|
45
45
|
"note": "Missing language support."
|
|
46
46
|
}
|
|
47
47
|
],
|