Bug 1330973 - WebsiteMetadata.jsm: Add description length to Metadata JSON. r=Grisha

MozReview-Commit-ID: 4zxaHPLEWJ6

--HG--
extra : rebase_source : 861de1b6e5f47435963d641aa6a2245f18a77128
This commit is contained in:
Sebastian Kaspari 2017-02-02 16:21:54 +01:00
Родитель fd87861e7b
Коммит 4e6612f2c4
1 изменённых файлов: 15 добавлений и 5 удалений

Просмотреть файл

@ -22,7 +22,8 @@ var WebsiteMetadata = {
Task.spawn(function() {
let metadata = getMetadata(doc, doc.location.href, {
image_url: metadataRules['image_url'],
provider: metadataRules['provider']
provider: metadataRules['provider'],
description_length: metadataRules['description_length']
});
// No metadata was extracted, so don't bother sending it.
@ -92,12 +93,21 @@ function buildRuleset(name, rules, processors) {
};
}
const descriptionRules = [
['meta[property="og:description"]', node => node.element.getAttribute('content')],
['meta[name="description"]', node => node.element.getAttribute('content')],
];
const metadataRules = {
description: {
rules: [
['meta[property="og:description"]', node => node.element.getAttribute('content')],
['meta[name="description"]', node => node.element.getAttribute('content')],
],
rules: descriptionRules
},
description_length: {
rules: descriptionRules,
processors: [
(description) => description.length
]
},
icon_url: {