Skip to content

armgit / clipy

Public Imported from GitHub
0

The AI-native screen recorder. Record your screen and talk; the people you share it with and your AI agents both get it.

fix(transcribe): ignore inherited language properties

Kashish Tiwari2247da37f92c
diff --git a/packages/transcribe/src/providers/common.ts b/packages/transcribe/src/providers/common.ts
index 2c82a6f..7d658ed 100644
--- a/packages/transcribe/src/providers/common.ts
+++ b/packages/transcribe/src/providers/common.ts
@@ -315,7 +315,7 @@ export function languageCode(raw: string | null | undefined): string | undefined
if (typeof raw !== "string") return undefined;
const value = raw.trim().toLowerCase();
if (!value) return undefined;
- const named = NAME_TO_CODE[value];
+ const named = Object.hasOwn(NAME_TO_CODE, value) ? NAME_TO_CODE[value] : undefined;
if (named) return named;
// The language subtag of a regional or script tag: en_us, en-US, zh-Hant-TW.
const base = value.split(/[-_]/)[0];
diff --git a/packages/transcribe/test/providers.test.ts b/packages/transcribe/test/providers.test.ts
index 33c3adc..fddfa5a 100644
--- a/packages/transcribe/test/providers.test.ts
+++ b/packages/transcribe/test/providers.test.ts
@@ -2114,6 +2114,12 @@ describe("languageCode", () => {
expect(languageCode(raw)).toBeUndefined();
});
});
+it.each(["constructor", "Constructor", "__proto__"])(
+ "does not treat prototype properties as language names: %s",
+ (raw) => {
+ expect(languageCode(raw)).toBeUndefined();
+ },
+);
describe("one language form across engines", () => {
it("normalises Gemini's language when the model answers with a name", async () => {