Skip to content

Commit 9d7728b

Browse files
feat(CSAF2.1): #356 add mandatory test 6.1.55 - use bcp47 to check language
1 parent 6e644ec commit 9d7728b

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

csaf_2_1/mandatoryTests/mandatoryTest_6_1_55.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Ajv from 'ajv/dist/jtd.js'
22
import { parse, validate } from 'license-expressions'
33
import license_information from '../../lib/license/license_information.js'
4+
import bcp47 from 'bcp47'
45

56
const ajv = new Ajv()
67

@@ -44,23 +45,6 @@ const inputSchema = /** @type {const} */ ({
4445

4546
const validateSchema = ajv.compile(inputSchema)
4647

47-
const ENGLISH_LANGUAGES = [
48-
'en',
49-
'en-AU',
50-
'en-BZ',
51-
'en-CA',
52-
'en-CB',
53-
'en-IE',
54-
'en-JM',
55-
'en-NZ',
56-
'en-PH',
57-
'en-PH',
58-
'en-TT',
59-
'en-US',
60-
'en-ZA',
61-
'en-ZW',
62-
]
63-
6448
const ABOUT_CODE_LICENSE_REF_PREFIX = 'LicenseRef-scancode-'
6549

6650
const ABOUT_CODE_LICENSE_KEYS = new Set(
@@ -141,7 +125,7 @@ export function existsNotListedLicenses(licenseToCheck) {
141125
* @returns {boolean} True if the language is valid, false otherwise
142126
*/
143127
export function isLangEnglishOrUnspecified(language) {
144-
return !language || ENGLISH_LANGUAGES.includes(language)
128+
return !language || bcp47.parse(language)?.langtag.language.language === 'en'
145129
}
146130

147131
/**

0 commit comments

Comments
 (0)