Skip to content

get headers from a user-agent #286

@Kikobeats

Description

@Kikobeats

Hello,

I love the library, I have been playing with it. It's very complete with lots of data 👏.

I was wondering if it would be possible to get headers from an input user agent instead of relaying them into browserlist.

So this is supported today:

const { HeaderGenerator, PRESETS } = require('header-generator');
const headerGenerator = new HeaderGenerator(PRESETS.MODERN_WINDOWS_CHROME);
console.log(headerGenerator.getHeaders())

and that is what I'm suggesting:

const { HeaderGenerator } = require('header-generator');

const userAgentString = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15';
const headerGenerator = HeaderGenerator.fromUserAgent(userAgentString);

console.log(headerGenerator.getHeaders())

This would be extremely helpful to have a more granular control to debug which cases can be detected or not.

Metadata

Metadata

Assignees

Labels

t-toolingIssues with this label are in the ownership of the tooling team.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions