jayco / accept-language-negotiator

RFC4647 compliant accept-language negotiator for parsing HTTP Accept-Language header and returning matched lists or language lookup.
MIT License
7 stars 3 forks source link

lookup return value #1

Open tregusti opened 6 years ago

tregusti commented 6 years ago

Hi,

I'm using 1.0.1 and when I'm using basicFilter like this:

const { basicFilter } = require("accept-language-negotiator")
const code = basicFilter('sv', ['sv-SE', 'en-UK'])[0]

code becomes sv-SE like I assumed. However when I'm trying to use lookup like this:

const { lookup } = require("accept-language-negotiator")
const code = lookup('sv', ['sv-SE', 'en-UK'], null)

I would assume that code would become sv-SE. But it is what I sent in instead, sv. I read section 3.4 in the lookup information in the RFC but can't really see that this is how it should be.

The first matching tag found, according to the user's priority, is considered the closest match and is the item returned.

Is this a bug in lookup?

jayco commented 4 years ago

Hi, I'm really sorry for the extremely late reply, thanks for taking the time to raise this issue. Yes, this appears to be a bug - will be updated if I get a chance to start working on v2 (I would be grateful for PR contributions).