Fix quotes with schema default values (#6968)

* Added quote trimming to schema default values

* Add return type to stripQuotes function

Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
Aiden Foxx
2021-07-26 18:37:45 +02:00
committed by GitHub
parent 961bc80e13
commit 27037f95c7
3 changed files with 20 additions and 2 deletions

View File

@@ -0,0 +1,16 @@
/**
* Strip leading/trailing quotes from a string
*/
export function stripQuotes(value: string | null): string | null {
if (value == null) {
return null;
}
const trimmed = value.trim();
if ((trimmed.startsWith(`'`) && trimmed.endsWith(`'`)) || (trimmed.startsWith('"') && trimmed.endsWith('"'))) {
return trimmed.slice(1, -1);
}
return value;
}