Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.49.24](https://github.com/microlinkhq/metascraper/compare/v5.49.23...v5.49.24) (2026-02-17)

### Bug Fixes

* **jsonld:** respect root nodes ([#799](https://github.com/microlinkhq/metascraper/issues/799)) ([b60173a](https://github.com/microlinkhq/metascraper/commit/b60173aa1e06966ac08b16d52c1ed4ae82bc7f33))

## [5.49.23](https://github.com/microlinkhq/metascraper/compare/v5.49.22...v5.49.23) (2026-02-17)

### Bug Fixes

* **helpers:** [@graph](https://github.com/graph) must be an array ([#798](https://github.com/microlinkhq/metascraper/issues/798)) ([9d58749](https://github.com/microlinkhq/metascraper/commit/9d587491ca9073f653d2bdb0eeb3fab241fe2041))

## [5.49.22](https://github.com/microlinkhq/metascraper/compare/v5.49.21...v5.49.22) (2026-01-30)

**Note:** Version bump only for package metascraper
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "5.49.22",
"version": "5.49.24",
"command": {
"bootstrap": {
"npmClientArgs": [
Expand Down
8 changes: 8 additions & 0 deletions packages/metascraper-amazon/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.49.24](https://github.com/microlinkhq/metascraper/compare/v5.49.23...v5.49.24) (2026-02-17)

**Note:** Version bump only for package metascraper-amazon

## [5.49.23](https://github.com/microlinkhq/metascraper/compare/v5.49.22...v5.49.23) (2026-02-17)

**Note:** Version bump only for package metascraper-amazon

## [5.49.21](https://github.com/microlinkhq/metascraper/compare/v5.49.20...v5.49.21) (2026-01-27)

**Note:** Version bump only for package metascraper-amazon
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-amazon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "metascraper-amazon",
"description": "Metascraper integration with Amazon",
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-amazon",
"version": "5.49.21",
"version": "5.49.24",
"types": "src/index.d.ts",
"main": "src/index.js",
"author": {
Expand Down
2 changes: 2 additions & 0 deletions packages/metascraper-amazon/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ module.exports = () => {

return rules
}

module.exports.test = test
29 changes: 29 additions & 0 deletions packages/metascraper-amazon/test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict'

const test = require('ava')

const { test: validator } = require('..')

test('true', t => {
t.true(validator('https://www.amazon.com/gp/product/B0057OC5O8/'))
t.true(validator('https://amazon.com/dp/B0123456789'))
t.true(validator('https://www.amazon.co.uk/dp/1849757097'))
t.true(validator('https://amazon.es/dp/B01MUGXRT9'))
t.true(validator('https://www.amazon.de/dp/B0123456789'))
t.true(validator('https://amazon.fr/dp/B0123456789'))
t.true(validator('https://www.amazon.it/dp/B0123456789'))
t.true(validator('https://amzn.to/abc123'))
t.true(validator('https://a.co/abc123'))
})

test('false', t => {
t.false(
validator(
'https://soundcloud.com/beautybrainsp/beauty-brain-swag-bandicoot'
)
)
t.false(validator('https://www.facebook.com/username/'))
t.false(validator('https://twitter.com/username/'))
t.false(validator('https://www.youtube.com/watch?v=123'))
t.false(validator('https://example.com'))
})
8 changes: 8 additions & 0 deletions packages/metascraper-audio/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.49.24](https://github.com/microlinkhq/metascraper/compare/v5.49.23...v5.49.24) (2026-02-17)

**Note:** Version bump only for package metascraper-audio

## [5.49.23](https://github.com/microlinkhq/metascraper/compare/v5.49.22...v5.49.23) (2026-02-17)

**Note:** Version bump only for package metascraper-audio

## [5.49.21](https://github.com/microlinkhq/metascraper/compare/v5.49.20...v5.49.21) (2026-01-27)

**Note:** Version bump only for package metascraper-audio
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-audio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "metascraper-audio",
"description": "Get audio property from HTML markup",
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-audio",
"version": "5.49.21",
"version": "5.49.24",
"types": "src/index.d.ts",
"main": "src/index.js",
"author": {
Expand Down
8 changes: 8 additions & 0 deletions packages/metascraper-author/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.49.24](https://github.com/microlinkhq/metascraper/packages/compare/v5.49.23...v5.49.24) (2026-02-17)

**Note:** Version bump only for package metascraper-author

## [5.49.23](https://github.com/microlinkhq/metascraper/packages/compare/v5.49.22...v5.49.23) (2026-02-17)

**Note:** Version bump only for package metascraper-author

## [5.49.21](https://github.com/microlinkhq/metascraper/packages/compare/v5.49.20...v5.49.21) (2026-01-27)

**Note:** Version bump only for package metascraper-author
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-author/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "metascraper-author",
"description": "Get author property from HTML markup",
"homepage": "https://metascraper.js.org",
"version": "5.49.21",
"version": "5.49.24",
"types": "src/index.d.ts",
"main": "src/index.js",
"author": {
Expand Down
8 changes: 8 additions & 0 deletions packages/metascraper-bluesky/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.49.24](https://github.com/microlinkhq/metascraper/compare/v5.49.23...v5.49.24) (2026-02-17)

**Note:** Version bump only for package metascraper-bluesky

## [5.49.23](https://github.com/microlinkhq/metascraper/compare/v5.49.22...v5.49.23) (2026-02-17)

**Note:** Version bump only for package metascraper-bluesky

## [5.49.21](https://github.com/microlinkhq/metascraper/compare/v5.49.20...v5.49.21) (2026-01-27)

**Note:** Version bump only for package metascraper-bluesky
2 changes: 1 addition & 1 deletion packages/metascraper-bluesky/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "metascraper-bluesky",
"description": "Metascraper integration with Bluesky",
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-bluesky",
"version": "5.49.21",
"version": "5.49.24",
"types": "src/index.d.ts",
"main": "src/index.js",
"author": {
Expand Down
8 changes: 8 additions & 0 deletions packages/metascraper-date/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.49.24](https://github.com/microlinkhq/metascraper/compare/v5.49.23...v5.49.24) (2026-02-17)

**Note:** Version bump only for package metascraper-date

## [5.49.23](https://github.com/microlinkhq/metascraper/compare/v5.49.22...v5.49.23) (2026-02-17)

**Note:** Version bump only for package metascraper-date

## [5.49.21](https://github.com/microlinkhq/metascraper/compare/v5.49.20...v5.49.21) (2026-01-27)

**Note:** Version bump only for package metascraper-date
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-date/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "metascraper-date",
"description": "Get date property from HTML markup",
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-date",
"version": "5.49.21",
"version": "5.49.24",
"types": "src/index.d.ts",
"main": "src/index.js",
"author": {
Expand Down
8 changes: 8 additions & 0 deletions packages/metascraper-description/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.49.24](https://github.com/microlinkhq/metascraper/compare/v5.49.23...v5.49.24) (2026-02-17)

**Note:** Version bump only for package metascraper-description

## [5.49.23](https://github.com/microlinkhq/metascraper/compare/v5.49.22...v5.49.23) (2026-02-17)

**Note:** Version bump only for package metascraper-description

## [5.49.21](https://github.com/microlinkhq/metascraper/compare/v5.49.20...v5.49.21) (2026-01-27)

**Note:** Version bump only for package metascraper-description
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-description/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "metascraper-description",
"description": "Get description property from HTML markup",
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-description",
"version": "5.49.21",
"version": "5.49.24",
"types": "src/index.d.ts",
"main": "src/index.js",
"author": {
Expand Down
8 changes: 8 additions & 0 deletions packages/metascraper-dribbble/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.49.24](https://github.com/microlinkhq/metascraper/compare/v5.49.23...v5.49.24) (2026-02-17)

**Note:** Version bump only for package metascraper-dribbble

## [5.49.23](https://github.com/microlinkhq/metascraper/compare/v5.49.22...v5.49.23) (2026-02-17)

**Note:** Version bump only for package metascraper-dribbble

## [5.49.22](https://github.com/microlinkhq/metascraper/compare/v5.49.21...v5.49.22) (2026-01-30)

**Note:** Version bump only for package metascraper-dribbble
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-dribbble/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "metascraper-dribbble",
"description": "Metascraper integration for Dribbble",
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-dribbble",
"version": "5.49.22",
"version": "5.49.24",
"types": "src/index.d.ts",
"main": "src/index.js",
"author": {
Expand Down
8 changes: 8 additions & 0 deletions packages/metascraper-feed/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.49.24](https://github.com/microlinkhq/metascraper/compare/v5.49.23...v5.49.24) (2026-02-17)

**Note:** Version bump only for package metascraper-feed

## [5.49.23](https://github.com/microlinkhq/metascraper/compare/v5.49.22...v5.49.23) (2026-02-17)

**Note:** Version bump only for package metascraper-feed

## [5.49.21](https://github.com/microlinkhq/metascraper/compare/v5.49.20...v5.49.21) (2026-01-27)

**Note:** Version bump only for package metascraper-feed
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-feed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "metascraper-feed",
"description": "Get RSS/Atom feed URL from HTML markup",
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-description",
"version": "5.49.21",
"version": "5.49.24",
"types": "src/index.d.ts",
"main": "src/index.js",
"author": {
Expand Down
12 changes: 12 additions & 0 deletions packages/metascraper-helpers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.49.24](https://github.com/microlinkhq/metascraper/compare/v5.49.23...v5.49.24) (2026-02-17)

### Bug Fixes

* **jsonld:** respect root nodes ([#799](https://github.com/microlinkhq/metascraper/issues/799)) ([b60173a](https://github.com/microlinkhq/metascraper/commit/b60173aa1e06966ac08b16d52c1ed4ae82bc7f33))

## [5.49.23](https://github.com/microlinkhq/metascraper/compare/v5.49.22...v5.49.23) (2026-02-17)

### Bug Fixes

* **helpers:** [@graph](https://github.com/graph) must be an array ([#798](https://github.com/microlinkhq/metascraper/issues/798)) ([9d58749](https://github.com/microlinkhq/metascraper/commit/9d587491ca9073f653d2bdb0eeb3fab241fe2041))

## [5.49.21](https://github.com/microlinkhq/metascraper/compare/v5.49.20...v5.49.21) (2026-01-27)

**Note:** Version bump only for package @metascraper/helpers
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@metascraper/helpers",
"description": "Collection of helper functions used by metascraper",
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-helpers",
"version": "5.49.21",
"version": "5.49.24",
"main": "src/index.js",
"author": {
"email": "hello@microlink.io",
Expand Down
10 changes: 6 additions & 4 deletions packages/metascraper-helpers/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,13 @@ const jsonld = memoizeOne(
const el = $(element)
const text = $(el).contents().text()
const json = parseJSON(text)
if (!json) return undefined
if (!json) return false
const { '@graph': graph, ...props } = json
if (!graph) return json
return graph.map(item => ({ ...props, ...item }))
return Array.isArray(graph)
? graph.map(item => ({ ...props, ...item }))
: graph
? props
: json
})
.get()
.filter(Boolean),
Expand All @@ -387,7 +390,6 @@ const jsonld = memoizeOne(
const $jsonld = propName => $ => {
const collection = jsonld($)
let value

collection.find(item => {
value = get(item, propName)
return !isEmpty(value) || isNumber(value) || isBoolean(value)
Expand Down
63 changes: 63 additions & 0 deletions packages/metascraper-helpers/test/jsonld.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,66 @@ test('returns empty array if JSON-LD is invalid', t => {
const $ = cheerio.load('<script type="application/ld+json">{{</script>')
t.deepEqual(jsonld($), [])
})

test('ignore @graph if it is not an array', t => {
const $ = cheerio.load(
'<script type="application/ld+json">{"@context":"http://schema.org","@graph":{"1":{"@id":"https://www.mobeforlife.com/#identity","@type":"MedicalOrganization","sameAs":["https://www.facebook.com/mobeforlife/","https://www.linkedin.com/company/mob%C4%93-llc","https://www.instagram.com/mobeforlife/"]},"2":{"@id":"#creator","@type":"Organization"},"3":{"@type":"BreadcrumbList","description":"Breadcrumbs list","itemListElement":[{"@type":"ListItem","item":"https://www.mobeforlife.com/","name":"Home","position":1},{"@type":"ListItem","item":"https://www.mobeforlife.com/blog/smart-goals-put-your-goals-within-reach","name":"SMART Goals: Put your goals within reach.","position":2}],"name":"Breadcrumbs"}}}</script>'
)

t.deepEqual(jsonld($), [{ '@context': 'http://schema.org' }])
})

test('respect root nodes under no @graph', t => {
const $ = cheerio.load(
'<script type="application/ld+json">[{"@type":"NewsArticle"},{"@type":"BreadcrumbList"}]</script>'
)
t.deepEqual(jsonld($), [
{ '@type': 'NewsArticle' },
{ '@type': 'BreadcrumbList' }
])
})

test('group all properties of the same node together', t => {
const $ = cheerio.load(`
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "Acme Inc"
}
</script>

<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "BreadcrumbList",
"name": "Breadcrumbs"
},
{
"@type": "Article",
"headline": "Hello World"
}
]
}
</script>`)

t.deepEqual(jsonld($), [
{
'@context': 'https://schema.org',
'@type': 'Organization',
name: 'Acme Inc'
},
{
'@context': 'https://schema.org',
'@type': 'BreadcrumbList',
name: 'Breadcrumbs'
},
{
'@context': 'https://schema.org',
'@type': 'Article',
headline: 'Hello World'
}
])
})
8 changes: 8 additions & 0 deletions packages/metascraper-iframe/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.49.24](https://github.com/microlinkhq/metascraper/compare/v5.49.23...v5.49.24) (2026-02-17)

**Note:** Version bump only for package metascraper-iframe

## [5.49.23](https://github.com/microlinkhq/metascraper/compare/v5.49.22...v5.49.23) (2026-02-17)

**Note:** Version bump only for package metascraper-iframe

## [5.49.21](https://github.com/microlinkhq/metascraper/compare/v5.49.20...v5.49.21) (2026-01-27)

**Note:** Version bump only for package metascraper-iframe
Expand Down
2 changes: 1 addition & 1 deletion packages/metascraper-iframe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "metascraper-iframe",
"description": "Embed a representation of an URL on third party sites",
"homepage": "https://github.com/microlinkhq/metascraper/packages/metascraper-iframe",
"version": "5.49.21",
"version": "5.49.24",
"types": "src/index.d.ts",
"main": "src/index.js",
"author": {
Expand Down
Loading
Loading