Socket
Socket
Sign inDemoInstall

wikipedia

Package Overview
Dependencies
11
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

0

dist/errors.d.ts

@@ -0,0 +0,0 @@ export declare class wikiError extends Error {

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { pageOptions, searchOptions, geoOptions, listOptions, eventOptions, fcOptions, randomFormats, pdfOptions, citationFormat, autocompletionOptions } from './optionTypes';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export declare const MSGS: {

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export interface searchOptions {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -0,0 +0,0 @@ import { coordinatesResult, imageResult, langLinksResult, notFound, pageResult, relatedResult, wikiMediaResult, wikiSummary } from './resultTypes';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ declare function makeRequest(params: any, redirect?: boolean): Promise<any>;

75

dist/request.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setAPIUrl = exports.returnRestUrl = exports.makeRestRequest = void 0;
const node_fetch_1 = require("node-fetch");
const axios_1 = require("axios");
const errors_1 = require("./errors");

@@ -11,25 +11,11 @@ let API_URL = 'https://en.wikipedia.org/w/api.php?', REST_API_URL = 'https://en.wikipedia.org/api/rest_v1/';

const USER_AGENT = 'wikipedia (https://github.com/dopecodez/Wikipedia/)';
// Makes a request to legacy php endpoint
async function makeRequest(params, redirect = true) {
async function callAPI(url) {
const options = {
headers: {
"Api-User-Agent": USER_AGENT,
},
};
try {
const search = { ...params };
search['format'] = 'json';
if (redirect) {
search['redirects'] = '';
}
if (!params.action)
search['action'] = "query";
search['origin'] = '*';
const options = {
headers: {
'Api-User-Agent': USER_AGENT,
}
};
let searchParam = '';
Object.keys(search).forEach(key => {
searchParam += `${key}=${search[key]}&`;
});
const response = await (0, node_fetch_1.default)(encodeURI(API_URL + searchParam), options);
const result = await response.json();
return result;
const { data } = await axios_1.default.get(url, options);
return data;
}

@@ -40,25 +26,25 @@ catch (error) {

}
// Makes a request to legacy php endpoint
async function makeRequest(params, redirect = true) {
const search = { ...params };
search['format'] = 'json';
if (redirect) {
search['redirects'] = '';
}
if (!params.action) {
search['action'] = "query";
}
search['origin'] = '*';
let searchParam = '';
Object.keys(search).forEach(key => {
searchParam += `${key}=${search[key]}&`;
});
return await callAPI(encodeURI(API_URL + searchParam));
}
// Makes a request to rest api endpoint
async function makeRestRequest(path, redirect = true) {
try {
if (!redirect) {
path += '?redirect=false';
}
const options = {
headers: {
'Api-User-Agent': USER_AGENT
}
};
const response = await (0, node_fetch_1.default)(encodeURI(REST_API_URL + path), options);
let result = await response.text();
try {
result = JSON.parse(result);
}
finally {
return result;
}
if (!redirect) {
path += '?redirect=false';
}
catch (error) {
throw new errors_1.wikiError(error);
}
return await callAPI(encodeURI(REST_API_URL + path));
}

@@ -68,4 +54,3 @@ exports.makeRestRequest = makeRestRequest;

function returnRestUrl(path) {
const url = encodeURI(REST_API_URL + path);
return url;
return encodeURI(REST_API_URL + path);
}

@@ -72,0 +57,0 @@ exports.returnRestUrl = returnRestUrl;

@@ -0,0 +0,0 @@ export interface wikiSearchResult {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -0,0 +0,0 @@ export declare function isString(title: any): boolean;

@@ -0,0 +0,0 @@ "use strict";

{
"name": "wikipedia",
"version": "2.0.0",
"version": "2.1.0",
"description": "A JavaScript wrapper for the wikipedia apis",

@@ -28,3 +28,2 @@ "main": "dist",

"@types/node": "^18.11.17",
"@types/node-fetch": "^2.5.7",
"@typescript-eslint/eslint-plugin": "^5.47.0",

@@ -43,4 +42,4 @@ "@typescript-eslint/parser": "^5.47.0",

"dependencies": {
"infobox-parser": "^3.6.2",
"node-fetch": "2.6.1"
"axios": "^1.4.0",
"infobox-parser": "^3.6.2"
},

@@ -47,0 +46,0 @@ "keywords": [

@@ -184,2 +184,9 @@ # WIKIPEDIA [![build](https://github.com/dopecodez/Wikipedia/workflows/build/badge.svg)](https://github.com/dopecodez/Wikipedia/actions) [![Test Coverage](https://api.codeclimate.com/v1/badges/a44c826dbef8c7f5ea45/test_coverage)](https://codeclimate.com/github/dopecodez/Wikipedia/test_coverage) [![Contributions](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dopecodez/Wikipedia/issues) [![npm version](https://badge.fury.io/js/wikipedia.svg)](https://badge.fury.io/js/wikipedia)

<td align="center">
<a href="https://github.com/gtibrett">
<img src="https://avatars.githubusercontent.com/u/47423?v=4" width="100;" alt="gtibrett"/>
<br />
<sub><b>Brett</b></sub>
</a>
</td>
<td align="center">
<a href="https://github.com/0xflotus">

@@ -197,3 +204,4 @@ <img src="https://avatars.githubusercontent.com/u/26602940?v=4" width="100;" alt="0xflotus"/>

</a>
</td>
</td></tr>
<tr>
<td align="center">

@@ -205,4 +213,3 @@ <a href="https://github.com/zactopus">

</a>
</td></tr>
<tr>
</td>
<td align="center">

@@ -209,0 +216,0 @@ <a href="https://github.com/bigmistqke">

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc