mediawiki-projects-list 1.1.2 → 1.2.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 CHANGED
@@ -10,6 +10,8 @@ declare module 'mediawiki-projects-list' {
10
10
  articlePath: string;
11
11
  /** Script path of the project */
12
12
  scriptPath: string;
13
+ /** Only exists when the hostname contains a single wiki: Full script path to the wiki */
14
+ fullScriptPath?: string;
13
15
  /** Only exists when the hostname contains multiple wikis: How to handle the id string */
14
16
  idString?: {
15
17
  /** Separator to join or split the id string on */
@@ -24,9 +26,9 @@ declare module 'mediawiki-projects-list' {
24
26
  /** Whether the paths include matches of the regex */
25
27
  regexPaths: boolean;
26
28
  /** Wiki farm of the project */
27
- wikiFarm: ("wikimedia" | "fandom" | "miraheze" | "wiki.gg" | "biligame" | "huijiwiki" | "shoutwiki") | null;
29
+ wikiFarm: ("biligame" | "fandom" | "huijiwiki" | "miraheze" | "shoutwiki" | "wiki.gg" | "wikimedia") | null;
28
30
  /** List of extensions providing useful API endpoints */
29
- extensions: ("CentralAuth" | "Cargo")[];
31
+ extensions: ("Cargo" | "CentralAuth" | "OAuth")[];
30
32
  /** Replacement for spaces in the article URL */
31
33
  urlSpaceReplacement: string;
32
34
  /** Note about the specific project */
package/index.js CHANGED
@@ -7,14 +7,15 @@ const {properties: {wikiProjects: {items: {properties: wikiProjectSchema}}}} = r
7
7
  * @property {string} regex - Regex to match the project url
8
8
  * @property {string} articlePath - Article path of the project
9
9
  * @property {string} scriptPath - Script path of the project
10
+ * @property {string} [fullScriptPath] - Only exists when the hostname contains a single wiki: Full script path to the wiki
10
11
  * @property {object} [idString] - Only exists when the hostname contains multiple wikis: How to handle the id string
11
12
  * @property {string} idString.separator - Separator to join or split the id string on
12
13
  * @property {"asc"|"desc"} idString.direction - Order in which the project regex additional group matches should be chained to gain the id string
13
14
  * @property {string} idString.regex - Regex to match the id string
14
15
  * @property {string[]} idString.scriptPaths - How to turn the group matches of the id string regex into an URL to the script path, index based on group matches
15
16
  * @property {boolean} regexPaths - Whether the paths include matches of the regex
16
- * @property {?("wikimedia"|"fandom"|"miraheze"|"wiki.gg"|"biligame"|"huijiwiki"|"shoutwiki")} wikiFarm - Wiki farm of the project
17
- * @property {("CentralAuth"|"Cargo")[]} extensions - List of extensions providing useful API endpoints
17
+ * @property {?("biligame"|"fandom"|"huijiwiki"|"miraheze"|"shoutwiki"|"wiki.gg"|"wikimedia")} wikiFarm - Wiki farm of the project
18
+ * @property {("Cargo"|"CentralAuth"|"OAuth")[]} extensions - List of extensions providing useful API endpoints
18
19
  * @property {string} urlSpaceReplacement - Replacement for spaces in the article URL
19
20
  * @property {?string} note - Note about the specific project
20
21
  */
@@ -59,8 +60,8 @@ function inputToWikiProject(input) {
59
60
  let result = null;
60
61
  let wikiProject = wikiProjects.find( wikiProject => input.split('/').slice(0, 3).some( part => part.endsWith( wikiProject.name ) ) );
61
62
  if ( wikiProject ) {
62
- let articlePath = ( wikiProject.regexPaths ? '/' : wikiProject.articlePath );
63
- let scriptPath = ( wikiProject.regexPaths ? '/' : wikiProject.scriptPath );
63
+ let articlePath = ( wikiProject.regexPaths ? '/' : wikiProject.articlePath.split('?')[0] ).replace(/[.*+?^${}()|\[\]\\]/g, '\\$&');
64
+ let scriptPath = ( wikiProject.regexPaths ? '/' : wikiProject.scriptPath ).replace(/[.*+?^${}()|\[\]\\]/g, '\\$&');
64
65
  let regex = input.match( new RegExp( wikiProject.regex + `(?:${articlePath}|${scriptPath}|/?$)` ) );
65
66
  if ( regex ) {
66
67
  if ( wikiProject.regexPaths ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediawiki-projects-list",
3
- "version": "1.1.2",
3
+ "version": "1.2.2",
4
4
  "type": "commonjs",
5
5
  "description": "List of MediaWiki projects for use in discord-wiki-bot",
6
6
  "main": "index.js",
@@ -32,6 +32,10 @@
32
32
  "type": "string",
33
33
  "description": "Script path of the project"
34
34
  },
35
+ "fullScriptPath": {
36
+ "type": "string",
37
+ "description": "Only exists when the hostname contains a single wiki: Full script path to the wiki"
38
+ },
35
39
  "idString": {
36
40
  "type": "object",
37
41
  "description": "Only exists when the hostname contains multiple wikis: How to handle the id string",
@@ -80,13 +84,13 @@
80
84
  "type": "string",
81
85
  "description": "Wiki farm of the project",
82
86
  "enum": [
83
- "wikimedia",
87
+ "biligame",
84
88
  "fandom",
89
+ "huijiwiki",
85
90
  "miraheze",
91
+ "shoutwiki",
86
92
  "wiki.gg",
87
- "biligame",
88
- "huijiwiki",
89
- "shoutwiki"
93
+ "wikimedia"
90
94
  ],
91
95
  "default": null
92
96
  },
@@ -97,8 +101,9 @@
97
101
  "type": "string",
98
102
  "description": "Name of an extension providing useful API endpoints",
99
103
  "enum": [
104
+ "Cargo",
100
105
  "CentralAuth",
101
- "Cargo"
106
+ "OAuth"
102
107
  ]
103
108
  },
104
109
  "default": [],