diff --git a/README.md b/README.md
index cedaca46..4f43d896 100644
--- a/README.md
+++ b/README.md
@@ -86,7 +86,7 @@ Supported tags and attributes:
- the `xlink:href` attribute of the `use` tag
- the `href` attribute of the `use` tag
- the `href` attribute of the `link` tag when the `rel` attribute contains `stylesheet`, `icon`, `shortcut icon`, `mask-icon`, `apple-touch-icon`, `apple-touch-icon-precomposed`, `apple-touch-startup-image`
-- the `content` attribute of the `meta` tag when the `name` attribute is `msapplication-tileimage`, `msapplication-square70x70logo`, `msapplication-square150x150logo`, `msapplication-wide310x150logo`, `msapplication-square310x310logo`, `msapplication-config`
+- the `content` attribute of the `meta` tag when the `name` attribute is `msapplication-tileimage`, `msapplication-square70x70logo`, `msapplication-square150x150logo`, `msapplication-wide310x150logo`, `msapplication-square310x310logo`, `msapplication-config` or when the `property` attribute is `og:image`, `og:image:url`, `og:image:secure_url`, `og:audio`, `og:audio:secure_url`, `og:video`, `og:video:secure_url`, `vk:image`
#### `Boolean`
diff --git a/src/utils.js b/src/utils.js
index 974bc3a9..30e0954b 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -428,7 +428,6 @@ function getAttributeValue(attributes, name) {
return attributes[lowercasedAttributes[name.toLowerCase()]];
}
-// TODO refactor
function scriptSrcFilter(tag, attribute, attributes) {
let type = getAttributeValue(attributes, 'type');
@@ -484,29 +483,54 @@ function linkHrefFilter(tag, attribute, attributes) {
function metaContentFilter(tag, attribute, attributes) {
let name = getAttributeValue(attributes, 'name');
- if (!name) {
- return false;
- }
+ if (name) {
+ name = name.trim();
+
+ if (!name) {
+ return false;
+ }
- name = name.trim();
+ name = name.toLowerCase();
- if (!name) {
- return false;
+ const allowedNames = [
+ // msapplication-TileImage
+ 'msapplication-tileimage',
+ 'msapplication-square70x70logo',
+ 'msapplication-square150x150logo',
+ 'msapplication-wide310x150logo',
+ 'msapplication-square310x310logo',
+ 'msapplication-config',
+ ];
+
+ return allowedNames.includes(name);
}
- name = name.toLowerCase();
+ let property = getAttributeValue(attributes, 'property');
- const allowedNames = [
- // msapplication-TileImage
- 'msapplication-tileimage',
- 'msapplication-square70x70logo',
- 'msapplication-square150x150logo',
- 'msapplication-wide310x150logo',
- 'msapplication-square310x310logo',
- 'msapplication-config',
- ];
+ if (property) {
+ property = property.trim();
+
+ if (!property) {
+ return false;
+ }
+
+ property = property.toLowerCase();
+
+ const allowedProperties = [
+ 'og:image',
+ 'og:image:url',
+ 'og:image:secure_url',
+ 'og:audio',
+ 'og:audio:secure_url',
+ 'og:video',
+ 'og:video:secure_url',
+ 'vk:image',
+ ];
+
+ return allowedProperties.includes(property);
+ }
- return allowedNames.includes(name);
+ return false;
}
const defaultAttributes = [
diff --git a/test/__snapshots__/attributes-option.test.js.snap b/test/__snapshots__/attributes-option.test.js.snap
index 37645f7d..314e3aff 100644
--- a/test/__snapshots__/attributes-option.test.js.snap
+++ b/test/__snapshots__/attributes-option.test.js.snap
@@ -764,7 +764,7 @@ var ___HTML_LOADER_REPLACEMENT_6___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(_
var ___HTML_LOADER_REPLACEMENT_7___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_7___);
var ___HTML_LOADER_REPLACEMENT_8___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_8___);
var ___HTML_LOADER_REPLACEMENT_9___ = ___HTML_LOADER_GET_SOURCE_FROM_IMPORT___(___HTML_LOADER_IMPORT_9___);
-var code = \\"\\\\n\\\\n
My First Heading
\\\\nMy first paragraph.
\\\\nAn Unordered HTML List
\\\\n\\\\n\\\\n - Coffee
\\\\n - Tea
\\\\n - Milk
\\\\n
\\\\n\\\\nAn Ordered HTML List
\\\\n\\\\n\\\\n - Coffee
\\\\n - Tea
\\\\n - Milk
\\\\n
\\\\n\\\\n\\\\n\\\\n\\\\n\\\\nFoo
\\\\n\\\\n\\\\nBAR
\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n\\\\n