mirror of
https://github.com/directus/directus.git
synced 2026-02-14 02:15:14 -05:00
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:
16
packages/schema/src/utils/strip-quotes.ts
Normal file
16
packages/schema/src/utils/strip-quotes.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user