html-get 2.17.0-2 → 2.17.0-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/html.js +6 -2
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "html-get",
|
|
3
3
|
"description": "Get the HTML from any website, fine-tuned for correction & speed",
|
|
4
4
|
"homepage": "https://nicedoc.com/microlinkhq/html-get",
|
|
5
|
-
"version": "2.17.0-
|
|
5
|
+
"version": "2.17.0-4",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"html-get": "bin/index.js"
|
package/src/html.js
CHANGED
|
@@ -90,19 +90,23 @@ const addBody = ({ url, headers, html }) => {
|
|
|
90
90
|
return `<!DOCTYPE html><html><head></head><body>${element}</body></html>`
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
const isOpenGraph = (prop = '') =>
|
|
94
|
+
['og:', 'fb:'].some(prefix => prop.startsWith(prefix))
|
|
95
|
+
|
|
93
96
|
const rewriteMetaTags = ({ $ }) => {
|
|
94
97
|
$('meta').each((_, element) => {
|
|
95
98
|
const el = $(element)
|
|
99
|
+
if (!el.attr('content')) return
|
|
96
100
|
|
|
97
101
|
const name = el.attr('name')
|
|
98
102
|
const property = el.attr('property')
|
|
99
103
|
|
|
100
104
|
// Convert 'name' to 'property' for Open Graph tags if 'property' is not already set correctly
|
|
101
|
-
if (name
|
|
105
|
+
if (isOpenGraph(name) && property !== name) {
|
|
102
106
|
el.removeAttr('name').attr('property', name)
|
|
103
107
|
debug('og', el.attr())
|
|
104
108
|
// Convert 'property' to 'name' for non-Open Graph tags
|
|
105
|
-
} else if (
|
|
109
|
+
} else if (!isOpenGraph(property)) {
|
|
106
110
|
el.removeAttr('property').attr('name', property)
|
|
107
111
|
debug('meta', el.attr())
|
|
108
112
|
}
|