html-get 2.17.0-1 → 2.17.0-3
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 +9 -8
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-3",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"html-get": "bin/index.js"
|
package/src/html.js
CHANGED
|
@@ -93,16 +93,17 @@ const addBody = ({ url, headers, html }) => {
|
|
|
93
93
|
const rewriteMetaTags = ({ $ }) => {
|
|
94
94
|
$('meta').each((_, element) => {
|
|
95
95
|
const el = $(element)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
if (!el.attr('content')) return
|
|
97
|
+
|
|
98
|
+
const name = el.attr('name')
|
|
99
|
+
const property = el.attr('property')
|
|
100
|
+
|
|
101
|
+
// Convert 'name' to 'property' for Open Graph tags if 'property' is not already set correctly
|
|
102
|
+
if (name?.startsWith('og:') && property !== name) {
|
|
100
103
|
el.removeAttr('name').attr('property', name)
|
|
101
104
|
debug('og', el.attr())
|
|
102
105
|
// Convert 'property' to 'name' for non-Open Graph tags
|
|
103
|
-
|
|
104
|
-
} else if (el.attr('property') && !el.attr('property').startsWith('og')) {
|
|
105
|
-
const property = el.attr('property')
|
|
106
|
+
} else if (property && !property.startsWith('og')) {
|
|
106
107
|
el.removeAttr('property').attr('name', property)
|
|
107
108
|
debug('meta', el.attr())
|
|
108
109
|
}
|
|
@@ -188,7 +189,7 @@ module.exports = ({
|
|
|
188
189
|
|
|
189
190
|
if (rewriteUrls) rewriteHtmlUrls({ $, url })
|
|
190
191
|
|
|
191
|
-
if (rewriteHtml) rewriteMetaTags({
|
|
192
|
+
if (rewriteHtml) rewriteMetaTags({ $, url })
|
|
192
193
|
|
|
193
194
|
addHead({ $, url, headers })
|
|
194
195
|
|