diff --git a/src/smapi.ts b/src/smapi.ts index 70bb450..a4a3e67 100644 --- a/src/smapi.ts +++ b/src/smapi.ts @@ -22,7 +22,7 @@ import { AccessTokens } from "./access_tokens"; import { BONOB_ACCESS_TOKEN_HEADER } from "./server"; import { Clock } from "./clock"; import { URLBuilder } from "./url_builder"; -import { I8N, LANG } from "./i8n"; +import { asLANGs, I8N } from "./i8n"; export const LOGIN_ROUTE = "/login"; export const CREATE_REGISTRATION_ROUTE = "/registration/add"; @@ -537,10 +537,10 @@ function bindSmapiSoapServiceToExpress( .then(({ musicLibrary, accessToken, type, typeId }) => { const paging = { _index: index, _count: count }; const acceptLanguage = headers["accept-language"]; - const lang = i8n((acceptLanguage || "en-US") as LANG); logger.debug( `Fetching metadata type=${type}, typeId=${typeId}, acceptLanguage=${acceptLanguage}` ); + const lang = i8n(...asLANGs(acceptLanguage)); const albums = (q: AlbumQuery): Promise => musicLibrary.albums(q).then((result) => { diff --git a/tests/smapi.test.ts b/tests/smapi.test.ts index de65763..28476e8 100644 --- a/tests/smapi.test.ts +++ b/tests/smapi.test.ts @@ -758,7 +758,7 @@ describe("api", () => { describe("when an accept-language header is present with value nl-NL", () => { 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({ id: "root", index: 0,