mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-10-24 21:41:16 +00:00
Merge pull request #332 from Jigsaw-Code/trevj-strip-whitespace
strip whitespace from server configs, like we used to
This commit is contained in:
commit
9507d2f8ef
2 changed files with 17 additions and 0 deletions
|
|
@ -46,4 +46,18 @@ describe('parseManualServerConfig', () => {
|
|||
expect(result.apiUrl).toEqual('http://abc.com/xyz');
|
||||
expect(result.certSha256).toEqual('1234567');
|
||||
});
|
||||
|
||||
it('strips whitespace', () => {
|
||||
const result =
|
||||
parseManualServerConfig('{"apiUrl":http://abc.com/xyz, "certSha256":"123 4567"}');
|
||||
expect(result.apiUrl).toEqual('http://abc.com/xyz');
|
||||
expect(result.certSha256).toEqual('1234567');
|
||||
});
|
||||
|
||||
it('strips newlines', () => {
|
||||
const result =
|
||||
parseManualServerConfig('{"apiUrl":http://abc.com/xyz, "certSha256":"123\n4567"}');
|
||||
expect(result.apiUrl).toEqual('http://abc.com/xyz');
|
||||
expect(result.certSha256).toEqual('1234567');
|
||||
});
|
||||
});
|
||||
|
|
@ -30,6 +30,9 @@ export function parseManualServerConfig(userInput: string): ManualServerConfig {
|
|||
userInput = userInput.substring(0, indexOfLastBrace + 1);
|
||||
}
|
||||
|
||||
// Strip whitespace.
|
||||
userInput = userInput.replace(/\s+/g, '');
|
||||
|
||||
const config = jsonic(userInput) as ManualServerConfig;
|
||||
|
||||
if (!config.apiUrl) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue