diff --git a/src/parseRawGrammar.ts b/src/parseRawGrammar.ts index f64614d..7373862 100644 --- a/src/parseRawGrammar.ts +++ b/src/parseRawGrammar.ts @@ -8,7 +8,7 @@ import { DebugFlags } from './debug'; import { parseJSON } from './json'; export function parseRawGrammar(content: string, filePath: string | null = null): IRawGrammar { - if (filePath !== null && /\.json$/.test(filePath)) { + if (filePath !== null && /\.json$/i.test(filePath)) { return parseJSONGrammar(content, filePath); } return parsePLISTGrammar(content, filePath); diff --git a/src/tests/parseRawGrammar.test.ts b/src/tests/parseRawGrammar.test.ts new file mode 100644 index 0000000..7d23d04 --- /dev/null +++ b/src/tests/parseRawGrammar.test.ts @@ -0,0 +1,14 @@ +/*--------------------------------------------------------- + * Copyright (C) Microsoft Corporation. All rights reserved. + *--------------------------------------------------------*/ + +import { test } from 'vitest'; +import * as assert from 'assert'; +import { parseRawGrammar } from '../main'; + +test('JSON grammars load with uppercase file extensions', () => { + const source = '{"scopeName":"source.example","patterns":[]}'; + const expected = parseRawGrammar(source, 'example.json'); + assert.deepStrictEqual(parseRawGrammar(source, 'example.JSON'), expected); + assert.deepStrictEqual(parseRawGrammar(source, 'example.Json'), expected); +});