Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
resolve-accept-language
Advanced tools
Resolve the preferred locale based on the value of an `Accept-Language` HTTP header.
Resolve the preferred locale based on the value of an Accept-Language
HTTP header.
Add the package as a dependency:
npm install resolve-accept-language
Code example:
import resolveAcceptLanguage from 'resolve-accept-language';
console.log(
resolveAcceptLanguage('fr-CA;q=0.01,en-CA;q=0.1,en-US;q=0.001', ['en-US', 'fr-CA'], 'en-US')
);
Output:
fr-CA
Accept-Language
package?The Accept-Language
header has been around since 1999. Like many other standards that deal with languages, the headers is based
on BCP 47 language tags. Language tags can be as simple as fr
(non country specific French) or more complex, for example
sr-Latn-RS
would represent latin script Serbian.
One of the main challenge is that BCP 47 language tags can be either overly simple or too complex. This is one of the problem this
library will try to address by focusing on locales identifier using the language
-country
format instead of trying to provide
full BCP 47 language tags support. The main reasons for this:
language
-country
format. We could possibly extend script support in the future but one the approach being this library is to keep it as simple as possible, while providing the best match.As per RFC 4647, this solution uses the "lookup" matching scheme. This means that it will always produce exactly one match for a given request.
The matching strategy will use the following rules:
FAQs
Resolve the preferred locale based on the value of an `Accept-Language` HTTP header.
The npm package resolve-accept-language receives a total of 36,646 weekly downloads. As such, resolve-accept-language popularity was classified as popular.
We found that resolve-accept-language demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.