jacktuck / unfurl

Metadata scraper with support for oEmbed, Twitter Cards and Open Graph Protocol for Node.js :zap:
MIT License
475 stars 51 forks source link

The "url" argument must be of type string. Received type undefined #43

Closed andreyvital closed 5 years ago

andreyvital commented 5 years ago

Getting:

The "url" argument must be of type string. Received type undefined

With: http://cityofcorona.maps.arcgis.com/apps/MapSeries/index.html?appid=6e3b7f35182a45d79d753bc4a6c543e0

Here's what being parsed out as metadata:

[
  [ 'title', 'City of Corona - Project Updates' ],
  [
    'keywords',
    [
      'JavaScript',   'layout-tab',
      'Map',          'Mapping Site',
      'mapseries',    'Online Map',
      'Ready To Use', 'selfConfigured',
      'Story Map',    'Story Maps',
      'Web Map',      'Corona'
    ]
  ],
  [
    'description',
    'This story map is a comprehensive look at all development projects going on in the city of Corona, CA.'
  ],
  [ 'twitter:card', undefined ],
  [ 'twitter:creator', undefined ],
  [ 'twitter:url', undefined ],
  [ 'twitter:title', undefined ],
  [ 'twitter:description', undefined ],
  [ 'twitter:image', undefined ],
  [ 'og:title', 'City of Corona - Project Updates' ],
  [
    'og:description',
    'This story map is a comprehensive look at all development projects going on in the city of Corona, CA.'
  ],
  [
    'og:url',
    'https://www.arcgis.com/home/item.html?id=6e3b7f35182a45d79d753bc4a6c543e0'
  ],
  [
    'og:image',
    'https://www.arcgis.com/sharing/rest/content/items/6e3b7f35182a45d79d753bc4a6c543e0/info/thumbnail/thumbnail.png'
  ],
  [ 'favicon', 'https://cityofcorona.maps.arcgis.com/favicon.ico' ]
]
andreyvital commented 5 years ago

It should be validating that we've got a valid URL to be resolved to:

if (item.type === "number") {
  metaValue = parseInt(metaValue, 10);
} else if (item.type === "url" && metaValue) {
  metaValue = resolveUrl(ctx.url, metaValue);
}

Here: https://github.com/jacktuck/unfurl/blob/master/src/index.ts#L334-L338

andreyvital commented 5 years ago

https://github.com/jacktuck/unfurl/pull/44