Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

accept-language-parser

Package Overview
Dependencies
Maintainers
4
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

accept-language-parser

Parse the accept-language header from a HTTP request

  • 1.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
376K
increased by3.59%
Maintainers
4
Weekly downloads
 
Created

What is accept-language-parser?

The accept-language-parser npm package is used to parse the Accept-Language header from HTTP requests. This header is used by browsers to indicate the user's language preferences. The package helps in extracting and interpreting these preferences, making it easier to serve content in the user's preferred language.

What are accept-language-parser's main functionalities?

Parse Accept-Language Header

This feature allows you to parse the Accept-Language header from an HTTP request. The code sample demonstrates how to parse a given Accept-Language header string and output the parsed languages as an array of objects.

const acceptLanguageParser = require('accept-language-parser');
const header = 'en-GB,en;q=0.9,fr;q=0.8,de;q=0.7';
const languages = acceptLanguageParser.parse(header);
console.log(languages);

Get Best Language Match

This feature allows you to find the best match for the user's language preferences from a list of supported languages. The code sample demonstrates how to use the 'pick' method to get the best matching language from the supported languages.

const acceptLanguageParser = require('accept-language-parser');
const header = 'en-GB,en;q=0.9,fr;q=0.8,de;q=0.7';
const supportedLanguages = ['en', 'fr', 'de'];
const bestMatch = acceptLanguageParser.pick(supportedLanguages, header);
console.log(bestMatch);

Other packages similar to accept-language-parser

Keywords

FAQs

Package last updated on 20 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc