-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add the 'Preferred-Languages' directive (#53)
The preferredLanguages key implements the Preferred-Languages directive. It can be passed a comma delimited string, or an array that will be converted into one. #50
- Loading branch information
Showing
3 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,3 +153,31 @@ test('uses new spelling with deprecated keys', () => { | |
|
||
expect(global.console.warn).toHaveBeenCalled() | ||
}) | ||
|
||
test('preferredLanguages directive works with multiple values', () => { | ||
const options = { | ||
contact: 'mailto:[email protected]', | ||
preferredLanguages: ['en', 'ru', 'es'] | ||
} | ||
|
||
const res = securityTxt.formatSecurityPolicy(options) | ||
|
||
expect(res).toBe( | ||
'Contact: mailto:[email protected]\n' + | ||
'Preferred-Languages: en, ru, es\n' | ||
) | ||
}) | ||
|
||
test('preferredLanguages directive works with one value only', () => { | ||
const options = { | ||
contact: 'mailto:[email protected]', | ||
preferredLanguages: 'en' | ||
} | ||
|
||
const res = securityTxt.formatSecurityPolicy(options) | ||
|
||
expect(res).toBe( | ||
'Contact: mailto:[email protected]\n' + | ||
'Preferred-Languages: en\n' | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters