mozilla / page-metadata-parser

DEPRECATED - A Javascript library for parsing metadata on a web page.
https://www.npmjs.com/package/page-metadata-parser
Mozilla Public License 2.0
270 stars 42 forks source link

Aliases for rules? #89

Closed artemjackson closed 7 years ago

artemjackson commented 7 years ago

With the given rule set

const ruleSet = {
  description: metadataRules.description,
  icon: metadataRules.icon_url,
  image: metadataRules.image_url,
  title: metadataRules.title
};

I got the result with duplicates such as icon and icon_url

{ 
  description: 'VK is the largest European social network with more than 100 million active users. Our goal is to keep old friends, ex-classmates, neighbours and co-workers in touch.',
  icon: 'https://vk.com/images/safari_152.png?1',
  image: undefined,
  title: 'Welcome! | VK',
  url: 'https://vk.com',
  provider: 'vk',
  icon_url: 'https://vk.com/favicon.ico'
}

Is it possible to alias icon_url as icon and have only icon in output?

jaredlockhart commented 7 years ago

Yeah you're right that was a holdover from attempting to maintain data structure compatibility with an older implementation of this thing for a certain project. That requirement doesn't exist anymore, so I've cleaned up the interface to be simpler and cleaner. Thanks for the feedback!