All files / Rindu/utils parseAcceptLanguage.ts

100% Statements 7/7
50% Branches 1/2
100% Functions 4/4
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 93x 1x 2x 2x     2x    
export function parseAcceptLanguage(acceptLanguage = ""): string[] {
  const languages = acceptLanguage.split(",").map((lang) => {
    const [code, q = "1"] = lang.trim().split(";q=");
    return { code: code.trim(), q: parseFloat(q) };
  });
 
  return languages.toSorted((a, b) => b.q - a.q).map(({ code }) => code);
}