mediawiki-projects-list 2.3.3 → 2.3.4
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.js +8 -6
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -100,19 +100,21 @@ function inputToWikiProject(input) {
|
|
|
100
100
|
let scriptPath = ( wikiProject.regexPaths ? '/' : wikiProject.scriptPath ).replace(/[.*+?^${}()|\[\]\\]/g, '\\$&');
|
|
101
101
|
let regex = input.match( new RegExp( wikiProject.regex + `(?:${articlePath}|${scriptPath}|/?$)` ) );
|
|
102
102
|
if ( regex ) {
|
|
103
|
+
scriptPath = wikiProject.scriptPath;
|
|
104
|
+
articlePath = wikiProject.articlePath;
|
|
103
105
|
if ( wikiProject.regexPaths ) {
|
|
104
|
-
scriptPath =
|
|
105
|
-
articlePath =
|
|
106
|
+
scriptPath = scriptPath.replace( /\$(\d)/g, (match, n) => regex[n] );
|
|
107
|
+
articlePath = articlePath.replace( /\$(\d)/g, (match, n) => regex[n] );
|
|
106
108
|
}
|
|
109
|
+
if ( articlePath.includes('?') && !articlePath.endsWith('=') ) {
|
|
110
|
+
articlePath = articlePath.replace( '?', '$1?' );
|
|
111
|
+
}
|
|
112
|
+
else articlePath += '$1';
|
|
107
113
|
result = {
|
|
108
114
|
fullArticlePath: 'https://' + regex[1] + articlePath,
|
|
109
115
|
fullScriptPath: 'https://' + regex[1] + scriptPath,
|
|
110
116
|
wikiProject: wikiProject
|
|
111
117
|
};
|
|
112
|
-
if ( result.fullArticlePath.includes('?') && !result.fullArticlePath.endsWith('=') ) {
|
|
113
|
-
result.fullArticlePath = result.fullArticlePath.replace( '?', '$1?' );
|
|
114
|
-
}
|
|
115
|
-
else result.fullArticlePath += '$1';
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
120
|
functionCache.inputToWikiProject.set(input, result);
|