open-graph-scraper
Advanced tools
Comparing version 6.1.0 to 6.2.0
# Change Log | ||
## 6.2.0 | ||
- 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 | ||
- Updating Dependencies | ||
## 6.1.0 | ||
@@ -4,0 +12,0 @@ |
@@ -42,2 +42,14 @@ "use strict"; | ||
}); | ||
// take all of the customMetaTags out of base of ogObject and store them into ogObject.customMetaTags | ||
if (options.customMetaTags) { | ||
options.customMetaTags.forEach((customMetaTag) => { | ||
if (ogObject[customMetaTag.fieldName]) { | ||
ogObject.customMetaTags = { | ||
...ogObject.customMetaTags, | ||
[customMetaTag.fieldName]: ogObject[customMetaTag.fieldName], | ||
}; | ||
delete ogObject[customMetaTag.fieldName]; | ||
} | ||
}); | ||
} | ||
// formats the multiple media values | ||
@@ -44,0 +56,0 @@ ogObject = (0, media_1.default)(ogObject); |
@@ -18,5 +18,5 @@ "use strict"; | ||
const { options } = (0, utils_1.optionSetup)(ogsOptions); | ||
if (options.html && options.url) | ||
throw new Error('Must specify either `url` or `html`, not both'); | ||
if (options.html) { | ||
if (options.url) | ||
throw new Error('Must specify either `url` or `html`, not both'); | ||
const ogObject = (0, extract_1.default)(options.html, options); | ||
@@ -23,0 +23,0 @@ ogObject.success = true; |
@@ -21,3 +21,3 @@ import type { RequestInit } from 'undici'; | ||
timeout?: number; | ||
url: string; | ||
url?: string; | ||
urlValidatorSettings?: ValidatorSettings; | ||
@@ -77,3 +77,3 @@ }; | ||
height?: number; | ||
type: string; | ||
type?: string; | ||
url: string; | ||
@@ -140,2 +140,5 @@ width?: number; | ||
charset?: string; | ||
customMetaTags?: { | ||
[key: string]: string | undefined; | ||
}; | ||
dcContributor?: string; | ||
@@ -172,6 +175,6 @@ dcCoverage?: string; | ||
musicSong?: MusicSongObject[]; | ||
musicSongDisc?: string | null[]; | ||
musicSongProperty?: string | null[]; | ||
musicSongTrack?: number | null[]; | ||
musicSongUrl?: string | null[]; | ||
musicSongDisc?: string | string[] | null[]; | ||
musicSongProperty?: string | string[] | null[]; | ||
musicSongTrack?: number | string[] | null[]; | ||
musicSongUrl?: string | string[] | null[]; | ||
ogArticleAuthor?: string; | ||
@@ -193,8 +196,8 @@ ogArticleExpirationTime?: string; | ||
ogImage?: ImageObject[]; | ||
ogImageHeight?: string | null[]; | ||
ogImageProperty?: string | null[]; | ||
ogImageSecureURL?: string | null[]; | ||
ogImageType?: string | null[]; | ||
ogImageURL?: string | null[]; | ||
ogImageWidth?: string | null[]; | ||
ogImageHeight?: string | string[] | null[]; | ||
ogImageProperty?: string | string[] | null[]; | ||
ogImageSecureURL?: string | string[] | null[]; | ||
ogImageType?: string | string[] | null[]; | ||
ogImageURL?: string | string[] | null[]; | ||
ogImageWidth?: string | string[] | null[]; | ||
ogLocale?: string; | ||
@@ -216,7 +219,7 @@ ogLocaleAlternate?: string; | ||
ogVideoActorId?: string; | ||
ogVideoHeight?: string | null[]; | ||
ogVideoProperty?: string | null[]; | ||
ogVideoHeight?: string | string[] | null[]; | ||
ogVideoProperty?: string | string[] | null[]; | ||
ogVideoSecureURL?: string; | ||
ogVideoType?: string | null[]; | ||
ogVideoWidth?: string | null[]; | ||
ogVideoType?: string | string[] | null[]; | ||
ogVideoWidth?: string | string[] | null[]; | ||
placeLocationLatitude?: string; | ||
@@ -259,13 +262,13 @@ placeLocationLongitude?: string; | ||
twitterImage?: TwitterImageObject[]; | ||
twitterImageAlt?: string | null[]; | ||
twitterImageHeight?: string | null[]; | ||
twitterImageProperty?: string | null[]; | ||
twitterImageSrc?: string | null[]; | ||
twitterImageWidth?: string | null[]; | ||
twitterImageAlt?: string | string[] | null[]; | ||
twitterImageHeight?: string | string[] | null[]; | ||
twitterImageProperty?: string | string[] | null[]; | ||
twitterImageSrc?: string | string[] | null[]; | ||
twitterImageWidth?: string | string[] | null[]; | ||
twitterPlayer?: TwitterPlayerObject[]; | ||
twitterPlayerHeight?: string | null[]; | ||
twitterPlayerProperty?: string | null[]; | ||
twitterPlayerStream?: string | null[]; | ||
twitterPlayerHeight?: string | string[] | null[]; | ||
twitterPlayerProperty?: string | string[] | null[]; | ||
twitterPlayerStream?: string | string[] | null[]; | ||
twitterPlayerStreamContentType?: string; | ||
twitterPlayerWidth?: string | null[]; | ||
twitterPlayerWidth?: string | string[] | null[]; | ||
twitterSite?: string; | ||
@@ -272,0 +275,0 @@ twitterSiteId?: string; |
{ | ||
"name": "open-graph-scraper", | ||
"description": "Node.js scraper module for Open Graph and Twitter Card info", | ||
"version": "6.1.0", | ||
"version": "6.2.0", | ||
"license": "MIT", | ||
@@ -13,4 +13,4 @@ "main": "./dist/index.js", | ||
"eslint": "eslint . --ext .js,.ts", | ||
"mocha:int": "ts-mocha --require ./tests/helpers/bootstrap.js --recursive \"./tests/integration/**/*.spec.js\" --timeout 10000", | ||
"mocha:unit": "nyc --reporter=html --reporter=text --exclude=tests/ ts-mocha --require ./tests/helpers/bootstrap.js --recursive \"./tests/unit/**/*.spec.js\"", | ||
"mocha:int": "ts-mocha --recursive \"./tests/integration/**/*.spec.ts\" --timeout 10000", | ||
"mocha:unit": "nyc --reporter=html --reporter=text --exclude=tests/ ts-mocha --recursive \"./tests/unit/**/*.spec.ts\"", | ||
"prepare": "npm run snyk-protect && npm run build", | ||
@@ -29,3 +29,3 @@ "snyk-protect": "snyk-protect", | ||
"dependencies": { | ||
"chardet": "^1.5.1", | ||
"chardet": "^1.6.0", | ||
"cheerio": "^1.0.0-rc.12", | ||
@@ -41,9 +41,10 @@ "undici": "^5.22.1", | ||
"devDependencies": { | ||
"@snyk/protect": "^1.1175.0", | ||
"@types/node": "^18.16.16", | ||
"@snyk/protect": "^1.1183.0", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^18.16.18", | ||
"@types/validator": "^13.7.17", | ||
"@typescript-eslint/eslint-plugin": "^5.59.9", | ||
"@typescript-eslint/parser": "^5.59.9", | ||
"@typescript-eslint/eslint-plugin": "^5.60.0", | ||
"@typescript-eslint/parser": "^5.60.0", | ||
"chai": "^4.3.7", | ||
"eslint": "^8.42.0", | ||
"eslint": "^8.43.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
@@ -56,5 +57,4 @@ "eslint-config-airbnb-typescript": "^17.0.0", | ||
"nyc": "^15.1.0", | ||
"sinon": "^15.1.0", | ||
"sinon": "^15.1.2", | ||
"ts-mocha": "^10.0.0", | ||
"tunnel": "^0.0.6", | ||
"typescript": "^5.1.3" | ||
@@ -61,0 +61,0 @@ }, |
@@ -85,3 +85,3 @@ # openGraphScraper | ||
const { result } = data; | ||
console.log('hostnameMetaTag:', result.hostnameMetaTag); // hostnameMetaTag: github.com | ||
console.log('hostnameMetaTag:', result.customMetaTags.hostnameMetaTag); // hostnameMetaTag: github.com | ||
}) | ||
@@ -128,6 +128,3 @@ ``` | ||
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 headers = new Headers({ | ||
'user-agent': userAgent, | ||
}); | ||
ogs({ url: 'https://www.wikipedia.org/', fetchOptions: { headers } }) | ||
ogs({ url: 'https://www.wikipedia.org/', fetchOptions: { headers: { 'user-agent': userAgent } } }) | ||
.then((data) => { | ||
@@ -134,0 +131,0 @@ const { error, html, result, response } = data; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87150
2092
136
Updatedchardet@^1.6.0