From 7162fdafdef2eaeab4aeca69e37762ee7e68204b Mon Sep 17 00:00:00 2001 From: jshemas Date: Fri, 9 Aug 2024 19:16:51 -0400 Subject: [PATCH 1/8] fixing typos --- CHANGELOG.md | 4 ++-- lib/extract.ts | 4 ++-- lib/fallback.ts | 4 ++-- lib/fields.ts | 4 ++-- lib/media.ts | 4 ++-- lib/types.ts | 4 ++-- lib/utils.ts | 8 ++++---- types/index.d.ts | 3 ++- types/lib/extract.d.ts | 4 ++-- types/lib/fallback.d.ts | 4 ++-- types/lib/fields.d.ts | 4 ++-- types/lib/media.d.ts | 4 ++-- types/lib/openGraphScraper.d.ts | 4 ++-- types/lib/types.d.ts | 9 +++++---- types/lib/utils.d.ts | 8 ++++---- 15 files changed, 37 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e365afb..025b78fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,7 +100,7 @@ - Modified the `url` property in `OpenGraphScraperOptions` to be an optional property since you don't need this when using just `html` - `Type` can optional in `ImageObject` since type is not set it it's invalid - Take all of the `customMetaTags` out of base of `ogObject` and store them into `ogObject.customMetaTags` -- The interal meta properties can be string arrays +- The internal meta properties can be string arrays - Updating Dependencies ## 6.1.0 @@ -119,7 +119,7 @@ - Replace `GOT` with [fetch](https://nodejs.org/docs/latest-v18.x/api/globals.html#fetch)! - Only supporting `node18` or higher going forward - Updated how options work. `Fetch` and `OGS` options no longer being mixed together, users can now set [fetch options](https://developer.mozilla.org/en-US/docs/Web/API/fetch#options) using `options.fetchOptions` -- Remove any ogImages/ogVideos/twitterImages/twitterPlayers/musicSongs resultes that have no url +- Remove any ogImages/ogVideos/twitterImages/twitterPlayers/musicSongs results that have no url - The `downloadLimit` option has been removed in favor of just using timeouts. - Limit ogImages/ogVideos/twitterImages/twitterPlayers/musicSongs to 10 items - Adding html to the `SuccessResult` of `OGS` diff --git a/lib/extract.ts b/lib/extract.ts index 7e3f644b..6887262d 100644 --- a/lib/extract.ts +++ b/lib/extract.ts @@ -5,7 +5,7 @@ import fields from './fields'; import mediaSetup from './media'; import { unescapeScriptText } from './utils'; -import type { OgObjectInteral, OpenGraphScraperOptions } from './types'; +import type { OgObjectInternal, OpenGraphScraperOptions } from './types'; /** * extract all of the meta tags needed for ogs @@ -16,7 +16,7 @@ import type { OgObjectInteral, OpenGraphScraperOptions } from './types'; * */ export default function extractMetaTags(body: string, options: OpenGraphScraperOptions) { - let ogObject: OgObjectInteral = { success: true }; + let ogObject: OgObjectInternal = { success: true }; const $ = load(body); const metaFields = fields; diff --git a/lib/fallback.ts b/lib/fallback.ts index 71639787..0d65392c 100644 --- a/lib/fallback.ts +++ b/lib/fallback.ts @@ -8,7 +8,7 @@ import { isUrlValid, } from './utils'; import type { - OpenGraphScraperOptions, ImageObject, OgObjectInteral, OnlyGetOpenGraphInfoItem, + OpenGraphScraperOptions, ImageObject, OgObjectInternal, OnlyGetOpenGraphInfoItem, } from './types'; const doesElementExist = (selector:string, attribute:string, $: CheerioAPI) => ( @@ -24,7 +24,7 @@ const doesElementExist = (selector:string, attribute:string, $: CheerioAPI) => ( * @return {object} object with ogs results with updated fallback values * */ -export function fallback(ogObject: OgObjectInteral, options: OpenGraphScraperOptions, $: CheerioAPI, body: string) { +export function fallback(ogObject: OgObjectInternal, options: OpenGraphScraperOptions, $: CheerioAPI, body: string) { const shouldFallback = (key: OnlyGetOpenGraphInfoItem): boolean => { if (!options.onlyGetOpenGraphInfo) { return true; diff --git a/lib/fields.ts b/lib/fields.ts index d47eba5a..3d07a3ee 100644 --- a/lib/fields.ts +++ b/lib/fields.ts @@ -1,9 +1,9 @@ -import type { OgObjectInteral } from './types'; +import type { OgObjectInternal } from './types'; type Fields = { multiple: boolean; property: string; - fieldName: keyof OgObjectInteral; + fieldName: keyof OgObjectInternal; }[]; /** diff --git a/lib/media.ts b/lib/media.ts index 3b5a4cda..67e14daf 100644 --- a/lib/media.ts +++ b/lib/media.ts @@ -3,7 +3,7 @@ import { removeNestedUndefinedValues } from './utils'; import type { ImageObject, MusicSongObject, - OgObjectInteral, + OgObjectInternal, TwitterImageObject, TwitterPlayerObject, VideoObject, @@ -84,7 +84,7 @@ const zip = (array: any, ...args: any) => { * @return {object} object with ogs results with updated media values * */ -export function mediaSetup(ogObject: OgObjectInteral) { +export function mediaSetup(ogObject: OgObjectInternal) { // sets ogImage property/width/height/type to empty array if one these exists if ( ogObject.ogImageSecureURL diff --git a/lib/types.ts b/lib/types.ts index 2c8def6a..acd352dd 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -115,7 +115,7 @@ export interface MusicSongObject { url: string; } -export interface OgObjectInteral { +export interface OgObjectInternal { alAndroidAppName?: string; alAndroidClass?: string; alAndroidPackage?: string; @@ -319,7 +319,7 @@ export interface OgObjectInteral { // Omit values from mediaMapperProperties export type OgObject = Omit< -OgObjectInteral, +OgObjectInternal, 'musicSongDisc' | 'musicSongProperty' | 'musicSongTrack' | diff --git a/lib/utils.ts b/lib/utils.ts index 9ecbb047..ee73b9f6 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -1,7 +1,7 @@ import isUrl from './isUrl'; import type { CustomMetaTags, - OgObjectInteral, + OgObjectInternal, OpenGraphScraperOptions, ValidatorSettings, } from './types'; @@ -93,13 +93,13 @@ export function isThisANonHTMLUrl(url: string): boolean { } /** - * Find and delete nested undefs + * Find and delete nested undefineds * * @param {object} object - object to be cleaned - * @return {object} object without nested undefs + * @return {object} object without nested undefineds * */ -export function removeNestedUndefinedValues(object: Record): OgObjectInteral { +export function removeNestedUndefinedValues(object: Record): OgObjectInternal { Object.entries(object).forEach(([key, value]) => { if (value && typeof value === 'object') removeNestedUndefinedValues(value); else if (value === undefined) delete object[key]; diff --git a/types/index.d.ts b/types/index.d.ts index 6b4ae829..f1a707ca 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -4,7 +4,8 @@ import type { ErrorResult, OpenGraphScraperOptions, SuccessResult } from './lib/ * for scraping Open Graph and Twitter Card info off a website. * * @param {object} options - The options used by Open Graph Scraper - * @param {boolean} [options.onlyGetOpenGraphInfo] - Only fetch open graph info and don't fall back on anything else. + * @param {boolean|string[]} [options.onlyGetOpenGraphInfo] - Only fetch open graph info and don't fall back on + * anything else. * @param {object} [options.customMetaTags] - Here you can define custom meta tags you want to scrape. * @param {object} [options.fetchOptions] - Sets the options used by fetch for the http requests * @param {object} [options.urlValidatorSettings] - Sets the options used by validator.js for testing the URL diff --git a/types/lib/extract.d.ts b/types/lib/extract.d.ts index e4868ce5..be179ec0 100644 --- a/types/lib/extract.d.ts +++ b/types/lib/extract.d.ts @@ -1,4 +1,4 @@ -import type { OgObjectInteral, OpenGraphScraperOptions } from './types'; +import type { OgObjectInternal, OpenGraphScraperOptions } from './types'; /** * extract all of the meta tags needed for ogs * @@ -7,4 +7,4 @@ import type { OgObjectInteral, OpenGraphScraperOptions } from './types'; * @return {object} object with ogs results * */ -export default function extractMetaTags(body: string, options: OpenGraphScraperOptions): OgObjectInteral; +export default function extractMetaTags(body: string, options: OpenGraphScraperOptions): OgObjectInternal; diff --git a/types/lib/fallback.d.ts b/types/lib/fallback.d.ts index bc549eb1..93f57b29 100644 --- a/types/lib/fallback.d.ts +++ b/types/lib/fallback.d.ts @@ -1,5 +1,5 @@ import type { CheerioAPI } from 'cheerio'; -import type { OpenGraphScraperOptions, OgObjectInteral } from './types'; +import type { OpenGraphScraperOptions, OgObjectInternal } from './types'; /** * ogs fallbacks * @@ -9,5 +9,5 @@ import type { OpenGraphScraperOptions, OgObjectInteral } from './types'; * @return {object} object with ogs results with updated fallback values * */ -export declare function fallback(ogObject: OgObjectInteral, options: OpenGraphScraperOptions, $: CheerioAPI, body: string): OgObjectInteral; +export declare function fallback(ogObject: OgObjectInternal, options: OpenGraphScraperOptions, $: CheerioAPI, body: string): OgObjectInternal; export default fallback; diff --git a/types/lib/fields.d.ts b/types/lib/fields.d.ts index 66da17e6..fcb0ebb8 100644 --- a/types/lib/fields.d.ts +++ b/types/lib/fields.d.ts @@ -1,8 +1,8 @@ -import type { OgObjectInteral } from './types'; +import type { OgObjectInternal } from './types'; type Fields = { multiple: boolean; property: string; - fieldName: keyof OgObjectInteral; + fieldName: keyof OgObjectInternal; }[]; /** * array of meta tags ogs is looking for diff --git a/types/lib/media.d.ts b/types/lib/media.d.ts index cb8f0d3d..fd33b1d1 100644 --- a/types/lib/media.d.ts +++ b/types/lib/media.d.ts @@ -1,4 +1,4 @@ -import type { OgObjectInteral } from './types'; +import type { OgObjectInternal } from './types'; /** * formats the multiple media values * @@ -7,5 +7,5 @@ import type { OgObjectInteral } from './types'; * @return {object} object with ogs results with updated media values * */ -export declare function mediaSetup(ogObject: OgObjectInteral): OgObjectInteral; +export declare function mediaSetup(ogObject: OgObjectInternal): OgObjectInternal; export default mediaSetup; diff --git a/types/lib/openGraphScraper.d.ts b/types/lib/openGraphScraper.d.ts index c47b95fc..70cf930c 100644 --- a/types/lib/openGraphScraper.d.ts +++ b/types/lib/openGraphScraper.d.ts @@ -7,13 +7,13 @@ import type { OpenGraphScraperOptions } from './types'; * */ export default function setOptionsAndReturnOpenGraphResults(ogsOptions: OpenGraphScraperOptions): Promise<{ - ogObject: import("./types").OgObjectInteral; + ogObject: import("./types").OgObjectInternal; response: { body: string; }; html: string; } | { - ogObject: import("./types").OgObjectInteral; + ogObject: import("./types").OgObjectInternal; response: import("undici").Response; html: string; }>; diff --git a/types/lib/types.d.ts b/types/lib/types.d.ts index cc86da38..6640a74d 100644 --- a/types/lib/types.d.ts +++ b/types/lib/types.d.ts @@ -11,13 +11,14 @@ export interface ErrorResult { response: undefined; result: OgObject; } +export type OnlyGetOpenGraphInfoItem = 'image' | 'title' | 'description' | 'locale' | 'logo' | 'url' | 'favicon' | 'audioUrl' | 'date'; /** * The options used by Open Graph Scraper * * @typeParam {string} url - URL of the site. (Required) * @typeParam {string} [html] - You can pass in an HTML string to run ogs on it. (use without options.url) * @typeParam {string[]} [blacklist] - Pass in an array of sites you don't want ogs to run on. - * @typeParam {boolean} [onlyGetOpenGraphInfo] - Only fetch open graph info and don't fall back on anything else. + * @typeParam {boolean | OnlyGetOpenGraphInfoItem[]} [onlyGetOpenGraphInfo] - Only fetch open graph info and don't fall back on anything else. * @typeParam {CustomMetaTags} [customMetaTags] - Here you can define custom meta tags you want to scrape. * @typeParam {Request} [fetchOptions] - The options passed into fetch. * @typeParam {number} [timeout] - Number of seconds before the fetch request ends. (default is 10 seconds) @@ -28,7 +29,7 @@ export interface OpenGraphScraperOptions { customMetaTags?: CustomMetaTags[]; fetchOptions?: RequestInit; html?: string; - onlyGetOpenGraphInfo?: boolean; + onlyGetOpenGraphInfo?: boolean | OnlyGetOpenGraphInfoItem[]; timeout?: number; url?: string; urlValidatorSettings?: ValidatorSettings; @@ -101,7 +102,7 @@ export interface MusicSongObject { track?: number; url: string; } -export interface OgObjectInteral { +export interface OgObjectInternal { alAndroidAppName?: string; alAndroidClass?: string; alAndroidPackage?: string; @@ -302,4 +303,4 @@ export interface OgObjectInteral { twitterUrl?: string; updatedTime?: string; } -export type OgObject = Omit; +export type OgObject = Omit; diff --git a/types/lib/utils.d.ts b/types/lib/utils.d.ts index 26a185cd..766c65b0 100644 --- a/types/lib/utils.d.ts +++ b/types/lib/utils.d.ts @@ -1,4 +1,4 @@ -import type { CustomMetaTags, OgObjectInteral, OpenGraphScraperOptions, ValidatorSettings } from './types'; +import type { CustomMetaTags, OgObjectInternal, OpenGraphScraperOptions, ValidatorSettings } from './types'; export declare const defaultUrlValidatorSettings: { allow_fragments: boolean; allow_protocol_relative_urls: boolean; @@ -58,13 +58,13 @@ export declare function isImageTypeValid(type: string): boolean; */ export declare function isThisANonHTMLUrl(url: string): boolean; /** - * Find and delete nested undefs + * Find and delete nested undefineds * * @param {object} object - object to be cleaned - * @return {object} object without nested undefs + * @return {object} object without nested undefineds * */ -export declare function removeNestedUndefinedValues(object: Record): OgObjectInteral; +export declare function removeNestedUndefinedValues(object: Record): OgObjectInternal; /** * Split the options object into ogs and got option objects * From 53200d77ceb20d86bc7034985b6ca72927279a6b Mon Sep 17 00:00:00 2001 From: jshemas Date: Fri, 9 Aug 2024 19:18:01 -0400 Subject: [PATCH 2/8] types can now be reached by open-graph-scraper/types --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e9336968..9a3b9e2e 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "import": "./dist/esm/index.js", "require": "./dist/cjs/index.js" }, - "./types/lib/types": "./types/lib/types.d.ts" + "./types": "./types/lib/types.d.ts" }, "scripts": { "build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir dist/cjs/", From 00bc39eb39b5079b6e1ce9887d246d4f8aa6b8b0 Mon Sep 17 00:00:00 2001 From: jshemas Date: Fri, 9 Aug 2024 19:22:51 -0400 Subject: [PATCH 3/8] updating userAgent example and setting it for the youtube tests --- README.md | 2 +- tests/integration/video.spec.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e22089ca..214c7acd 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ The request header is set to [undici](https://github.com/nodejs/undici) by defau ```javascript const ogs = require("open-graph-scraper"); -const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'; +const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36'; ogs({ url: 'https://www.wikipedia.org/', fetchOptions: { headers: { 'user-agent': userAgent } } }) .then((data) => { const { error, html, result, response } = data; diff --git a/tests/integration/video.spec.ts b/tests/integration/video.spec.ts index eda627f5..bd9ac835 100644 --- a/tests/integration/video.spec.ts +++ b/tests/integration/video.spec.ts @@ -4,7 +4,8 @@ import ogs from '../../index'; describe('video', function () { it('Test Youtube Video - Should Return correct Open Graph Info', function () { - return ogs({ url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ' }).then(function ({ error, result, response }) { + const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36'; + return ogs({ url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', fetchOptions: { headers: { 'user-agent': userAgent } } }).then(function ({ error, result, response }) { console.log('error:', error); console.log('result:', result); expect(error).to.be.eql(false); @@ -111,7 +112,8 @@ describe('video', function () { }); it('Test Youtube Video with bad escape sequence - Should Return correct Open Graph Info', function () { - return ogs({ url: 'https://www.youtube.com/watch?v=nFbKMg4E3JM' }).then(function ({ error, result, response }) { + const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36'; + return ogs({ url: 'https://www.youtube.com/watch?v=nFbKMg4E3JM', fetchOptions: { headers: { 'user-agent': userAgent } } }).then(function ({ error, result, response }) { console.log('error:', error); console.log('result:', result); expect(error).to.be.eql(false); From d795dffe3c1f8016a12ac9fa2df663b5927cfa00 Mon Sep 17 00:00:00 2001 From: jshemas Date: Fri, 9 Aug 2024 19:35:34 -0400 Subject: [PATCH 4/8] skipping tests for now --- tests/integration/video.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/integration/video.spec.ts b/tests/integration/video.spec.ts index bd9ac835..7097c473 100644 --- a/tests/integration/video.spec.ts +++ b/tests/integration/video.spec.ts @@ -2,7 +2,8 @@ import { expect } from 'chai'; import ogs from '../../index'; -describe('video', function () { +// TODO: youtube is blocking requests from github, will need to find a way around this +describe.skip('video', function () { it('Test Youtube Video - Should Return correct Open Graph Info', function () { const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36'; return ogs({ url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', fetchOptions: { headers: { 'user-agent': userAgent } } }).then(function ({ error, result, response }) { From ba6741be32ead00ee8221c699c69b7a0995069ac Mon Sep 17 00:00:00 2001 From: jshemas Date: Sat, 17 Aug 2024 14:18:19 -0400 Subject: [PATCH 5/8] updating dependencies --- package-lock.json | 40 ++++++++++++++++++++-------------------- package.json | 10 +++++----- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index be008d70..26e218d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,12 +12,12 @@ "chardet": "^2.0.0", "cheerio": "^1.0.0-rc.12", "iconv-lite": "^0.6.3", - "undici": "^6.19.5" + "undici": "^6.19.7" }, "devDependencies": { - "@snyk/protect": "^1.1292.2", + "@snyk/protect": "^1.1292.4", "@types/mocha": "^10.0.7", - "@types/node": "^18.19.42", + "@types/node": "^18.19.44", "@typescript-eslint/eslint-plugin": "^7.18.0", "@typescript-eslint/parser": "^7.18.0", "chai": "^4.5.0", @@ -26,8 +26,8 @@ "eslint-config-airbnb-typescript": "^18.0.0", "eslint-plugin-import": "^2.29.1", "eslint-plugin-mocha": "^10.5.0", - "eslint-plugin-promise": "^7.0.0", - "mocha": "^10.6.0", + "eslint-plugin-promise": "^7.1.0", + "mocha": "^10.7.3", "nyc": "^17.0.0", "sinon": "^18.0.0", "ts-mocha": "^10.0.0", @@ -786,9 +786,9 @@ "dev": true }, "node_modules/@snyk/protect": { - "version": "1.1292.2", - "resolved": "https://registry.npmjs.org/@snyk/protect/-/protect-1.1292.2.tgz", - "integrity": "sha512-8qPdZqB7efG6I82uO5FAJuPoAGsjtQ8vWsbFOiQFZmQKUtTn5/bU1qoOYOLPXTDCCxsN6n0AzlDRd8DenX9Uew==", + "version": "1.1292.4", + "resolved": "https://registry.npmjs.org/@snyk/protect/-/protect-1.1292.4.tgz", + "integrity": "sha512-13ZSAV6fBIx/DtM4WyN/aeWaWQO8vV7RoSXxLefZ4V4oUBZ+LfsR2VdCM2Qo8aQaUK7/YlBgZo8To8MEn9Iocg==", "dev": true, "bin": { "snyk-protect": "bin/snyk-protect" @@ -810,9 +810,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "18.19.42", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.42.tgz", - "integrity": "sha512-d2ZFc/3lnK2YCYhos8iaNIYu9Vfhr92nHiyJHRltXWjXUBjEE+A4I58Tdbnw4VhggSW+2j5y5gTrLs4biNnubg==", + "version": "18.19.44", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.44.tgz", + "integrity": "sha512-ZsbGerYg72WMXUIE9fYxtvfzLEuq6q8mKERdWFnqTmOvudMxnz+CBNRoOwJ2kNpFOncrKjT1hZwxjlFgQ9qvQA==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -2325,9 +2325,9 @@ } }, "node_modules/eslint-plugin-promise": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-7.0.0.tgz", - "integrity": "sha512-wb1ECT+b90ndBdAujhIdAU8oQ3Vt5gKqP/t78KOmg0ifynrvc2jGR9f6ndbOVNFpKf6jLUBlBBDF3H3Wk0JICg==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-7.1.0.tgz", + "integrity": "sha512-8trNmPxdAy3W620WKDpaS65NlM5yAumod6XeC4LOb+jxlkG4IVcp68c6dXY2ev+uT4U1PtG57YDV6EGAXN0GbQ==", "dev": true, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -3832,9 +3832,9 @@ } }, "node_modules/mocha": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.7.0.tgz", - "integrity": "sha512-v8/rBWr2VO5YkspYINnvu81inSz2y3ODJrhO175/Exzor1RcEZZkizgE2A+w/CAXXoESS8Kys5E62dOHGHzULA==", + "version": "10.7.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.7.3.tgz", + "integrity": "sha512-uQWxAu44wwiACGqjbPYmjo7Lg8sFrS3dQe7PP2FQI+woptP4vZXSMcfMyFL/e1yFEeEpV4RtyTpZROOKmxis+A==", "dev": true, "dependencies": { "ansi-colors": "^4.1.3", @@ -5468,9 +5468,9 @@ } }, "node_modules/undici": { - "version": "6.19.5", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.19.5.tgz", - "integrity": "sha512-LryC15SWzqQsREHIOUybavaIHF5IoL0dJ9aWWxL/PgT1KfqAW5225FZpDUFlt9xiDMS2/S7DOKhFWA7RLksWdg==", + "version": "6.19.7", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.19.7.tgz", + "integrity": "sha512-HR3W/bMGPSr90i8AAp2C4DM3wChFdJPLrWYpIS++LxS8K+W535qftjt+4MyjNYHeWabMj1nvtmLIi7l++iq91A==", "engines": { "node": ">=18.17" } diff --git a/package.json b/package.json index 9a3b9e2e..d1d71823 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "chardet": "^2.0.0", "cheerio": "^1.0.0-rc.12", "iconv-lite": "^0.6.3", - "undici": "^6.19.5" + "undici": "^6.19.7" }, "files": [ "/dist", @@ -48,9 +48,9 @@ "CHANGELOG.md" ], "devDependencies": { - "@snyk/protect": "^1.1292.2", + "@snyk/protect": "^1.1292.4", "@types/mocha": "^10.0.7", - "@types/node": "^18.19.42", + "@types/node": "^18.19.44", "@typescript-eslint/eslint-plugin": "^7.18.0", "@typescript-eslint/parser": "^7.18.0", "chai": "^4.5.0", @@ -59,8 +59,8 @@ "eslint-config-airbnb-typescript": "^18.0.0", "eslint-plugin-import": "^2.29.1", "eslint-plugin-mocha": "^10.5.0", - "eslint-plugin-promise": "^7.0.0", - "mocha": "^10.6.0", + "eslint-plugin-promise": "^7.1.0", + "mocha": "^10.7.3", "nyc": "^17.0.0", "sinon": "^18.0.0", "ts-mocha": "^10.0.0", From ce5f735692d22768093620e2ef14acce2ea46f03 Mon Sep 17 00:00:00 2001 From: jshemas Date: Sat, 17 Aug 2024 14:26:00 -0400 Subject: [PATCH 6/8] updating the readme on how to get types --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 214c7acd..483509d1 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,31 @@ Check the return for a ```success``` flag. If success is set to true, then the u Note: `open-graph-scraper` uses the [Fetch API](https://nodejs.org/dist/latest-v18.x/docs/api/globals.html#fetch) for requests and most of [Fetch's options](https://developer.mozilla.org/en-US/docs/Web/API/fetch#options) should work as `open-graph-scraper`'s `fetchOptions` options. +## Types And Import Example + +```javascript +// example of how to get types +import type { SuccessResult } from 'open-graph-scraper/types'; +const example: SuccessResult = { + result: { ogTitle: 'this is a title' }, + error: false, + response: {}, + html: '' +} + +// import example +import ogs from 'open-graph-scraper'; +const options = { url: 'http://ogp.me/' }; +ogs(options) + .then((data) => { + const { error, html, result, response } = data; + console.log('error:', error); // This returns true or false. True if there was an error. The error itself is inside the result object. + console.log('html:', html); // This contains the HTML of page + console.log('result:', result); // This contains all of the Open Graph results + console.log('response:', response); // This contains response from the Fetch API + }); +``` + ## Custom Meta Tag Example ```javascript From b89d66311f1942e0cae7cf75453438eb934715ee Mon Sep 17 00:00:00 2001 From: jshemas Date: Sat, 17 Aug 2024 14:31:22 -0400 Subject: [PATCH 7/8] updating changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 025b78fe..2dda0ccb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 6.8.0 + +- Updating how `onlyGetOpenGraphInfo` works. By default it is `false` but now it accepts an array of properties for which no fallback should be used. +- Updating how you get types `import { SuccessResult } from 'open-graph-scraper/types';`. See readme for details. +- Updating dependencies + ## 6.7.2 - Adding `types` to the npm export. You can now use `import { SuccessResult } from 'open-graph-scraper/types/lib/types';` From 4eda428ceb72aa257894bae865642773d0002ae4 Mon Sep 17 00:00:00 2001 From: jshemas Date: Sat, 17 Aug 2024 14:31:44 -0400 Subject: [PATCH 8/8] 6.8.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 26e218d0..7b817f09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "open-graph-scraper", - "version": "6.7.2", + "version": "6.8.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "open-graph-scraper", - "version": "6.7.2", + "version": "6.8.0", "license": "MIT", "dependencies": { "chardet": "^2.0.0", diff --git a/package.json b/package.json index d1d71823..2751529e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "open-graph-scraper", "description": "Node.js scraper module for Open Graph and Twitter Card info", - "version": "6.7.2", + "version": "6.8.0", "license": "MIT", "main": "./dist/cjs/index.js", "types": "./types/index.d.ts",