jacktuck / unfurl

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

Add support for Accept-Language header #93

Closed StefKors closed 1 year ago

StefKors commented 2 years ago

Adds support for setting a Accept-Language header on fetch

jacktuck commented 2 years ago

Hi Stef. Thanks for the PR.

Whilst this PR does look fine, I think we should take a more general approach such that any headers can be provided.

I'd be open to a breaking change where we can provide a headers object, we should use the interface supplied by Fetch for this I think, i.e. https://github.com/node-fetch/node-fetch#new-headersinit

So the opts would end up looking something like this

### `unfurl(url [, opts])`
#### url - `string`
---
#### opts - `object` of:
-  `oembed?: boolean` - support retrieving oembed metadata
-  `timeout?  number` - req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies) 
-  `follow?: number` - maximum redirect count. 0 to not follow redirect
-  `compress?: boolean` - support gzip/deflate content encoding 
-  `size?: number` - maximum response body size in bytes. 0 to disable 
-  `headers?: Headers` - map of request headers, overrides the defaults
StefKors commented 2 years ago

even better, I'll update the MR 👍

StefKors commented 2 years ago

@jacktuck It's ready for your review 👍

jacktuck commented 2 years ago

@StefKors Thanks! At first glance, this looks good 👍 I'll have a proper look soon.

jacktuck commented 1 year ago

Released in 6.0.0