Comparing version
@@ -11,2 +11,3 @@ "use strict"; | ||
const axios_1 = __importDefault(require("axios")); | ||
const axios_2 = require("axios"); | ||
axios_1.default.interceptors.response.use(response => { | ||
@@ -64,6 +65,6 @@ let enc = (response.headers['content-type']?.match(/charset=(.+)/) || []).pop(); | ||
timeout: 20000, | ||
headers: { | ||
headers: new axios_2.AxiosHeaders({ | ||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', | ||
'User-Agent': this._userAgent | ||
}, | ||
}), | ||
maxRedirects: 5 | ||
@@ -87,3 +88,2 @@ }; | ||
if (typeof options === 'object') { | ||
lodash_1.default.merge(http_options.headers, options.http?.headers || {}); | ||
http_options.timeout = options.http?.timeout || http_options.timeout; | ||
@@ -93,2 +93,3 @@ http_options.maxRedirects = options.http?.maxRedirects || http_options.maxRedirects; | ||
userAgent = options.userAgent || userAgent; | ||
http_options.headers?.set(options.http?.headers || {}); | ||
} | ||
@@ -95,0 +96,0 @@ (0, axios_1.default)({ |
/// <reference types="node" /> | ||
import { URL } from 'url'; | ||
import { Language } from "langs"; | ||
import type { AxiosResponseHeaders } from "axios"; | ||
import { RawAxiosRequestHeaders } from "axios"; | ||
export interface MetafetchResponse { | ||
@@ -21,5 +21,5 @@ title?: string; | ||
}; | ||
headers?: AxiosResponseHeaders; | ||
headers?: RawAxiosRequestHeaders; | ||
} | ||
export default function (url: string, options: any, body: string, headers: AxiosResponseHeaders, franc: ((value?: string | undefined) => string) | ((arg0: string) => string)): MetafetchResponse; | ||
export default function (url: string, options: any, body: string, headers: RawAxiosRequestHeaders, franc: ((value?: string | undefined) => string) | ((arg0: string) => string)): MetafetchResponse; | ||
//# sourceMappingURL=parser.d.ts.map |
@@ -26,3 +26,3 @@ "use strict"; | ||
if (options.charset) { | ||
response.charset = $("meta[charset]").attr("charset") || (headers['content-type']?.match(/charset=(.+)/) || []).pop(); | ||
response.charset = $("meta[charset]").attr("charset") || (headers['content-type']?.toString().match(/charset=(.+)/) || []).pop(); | ||
} | ||
@@ -98,3 +98,3 @@ if (options.images) { | ||
if (options.language) { | ||
response.language = $("html").attr("lang") || $("html").attr("xml:lang") || headers["Content-Language"] || headers["content-language"]; | ||
response.language = $("html").attr("lang") || $("html").attr("xml:lang") || headers["Content-Language"]?.toString() || headers["content-language"]?.toString(); | ||
if (typeof response.language == "string") { | ||
@@ -101,0 +101,0 @@ response.language = response.language.split("-")[0]; |
{ | ||
"name": "metafetch", | ||
"description": "Metafetch fetches a given URL's title, description, images, links etc.", | ||
"version": "3.1.2", | ||
"version": "3.1.3", | ||
"homepage": "https://github.com/brahma-dev/metafetch", | ||
@@ -24,3 +24,3 @@ "repository": { | ||
"dependencies": { | ||
"axios": "^0.28.0", | ||
"axios": "^1.6.7", | ||
"cheerio": "^1.0.0-rc.12", | ||
@@ -27,0 +27,0 @@ "franc": "^6.2.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
32582
0.43%367
0.27%+ Added
- Removed
Updated