huyha85 / opengraph_parser

Simple Ruby Parser library for parsing OpenGraph protocol (http://ogp.me)
MIT License
59 stars 28 forks source link

Check for scheme and host before fetching url content #19

Closed yurikoval closed 6 years ago

yurikoval commented 6 years ago

Some html content gets misinterpreted as URL, which causes Addressable::URI::InvalidURIError. To prevent this error, we can check for a valid schema and host set in src before we attempt to fetch the URL.

Sample HTML:

<!DOCTYPE html>
<html>
  <head>
    <meta name="twitter:title" property="og:title" itemprop="title name" content="OpenGraph Title" />
    <meta property="og:url" content="https://www.example.com/page.html" />
  </head>
</html>
yurikoval commented 6 years ago

Closing in favor of https://github.com/mobomo/opengraph