Fix bug where langs incorrectly determined in smapi

This commit is contained in:
simojenki
2021-08-16 23:46:47 +10:00
parent 432248fb47
commit 3545d9c653
2 changed files with 3 additions and 3 deletions

View File

@@ -22,7 +22,7 @@ import { AccessTokens } from "./access_tokens";
import { BONOB_ACCESS_TOKEN_HEADER } from "./server"; import { BONOB_ACCESS_TOKEN_HEADER } from "./server";
import { Clock } from "./clock"; import { Clock } from "./clock";
import { URLBuilder } from "./url_builder"; import { URLBuilder } from "./url_builder";
import { I8N, LANG } from "./i8n"; import { asLANGs, I8N } from "./i8n";
export const LOGIN_ROUTE = "/login"; export const LOGIN_ROUTE = "/login";
export const CREATE_REGISTRATION_ROUTE = "/registration/add"; export const CREATE_REGISTRATION_ROUTE = "/registration/add";
@@ -537,10 +537,10 @@ function bindSmapiSoapServiceToExpress(
.then(({ musicLibrary, accessToken, type, typeId }) => { .then(({ musicLibrary, accessToken, type, typeId }) => {
const paging = { _index: index, _count: count }; const paging = { _index: index, _count: count };
const acceptLanguage = headers["accept-language"]; const acceptLanguage = headers["accept-language"];
const lang = i8n((acceptLanguage || "en-US") as LANG);
logger.debug( logger.debug(
`Fetching metadata type=${type}, typeId=${typeId}, acceptLanguage=${acceptLanguage}` `Fetching metadata type=${type}, typeId=${typeId}, acceptLanguage=${acceptLanguage}`
); );
const lang = i8n(...asLANGs(acceptLanguage));
const albums = (q: AlbumQuery): Promise<GetMetadataResponse> => const albums = (q: AlbumQuery): Promise<GetMetadataResponse> =>
musicLibrary.albums(q).then((result) => { musicLibrary.albums(q).then((result) => {

View File

@@ -758,7 +758,7 @@ describe("api", () => {
describe("when an accept-language header is present with value nl-NL", () => { describe("when an accept-language header is present with value nl-NL", () => {
it("should return nl-NL", async () => { it("should return nl-NL", async () => {
ws.addHttpHeader("accept-language", "nl-NL") ws.addHttpHeader("accept-language", "nl-NL, en-US;q=0.9")
const root = await ws.getMetadataAsync({ const root = await ws.getMetadataAsync({
id: "root", id: "root",
index: 0, index: 0,