fix: edge case in unquote function (when null)

This commit is contained in:
Chesterkxng
2025-04-06 01:45:56 +02:00
parent b96c12bbd2
commit f6fd1d9a04

View File

@@ -54,7 +54,11 @@ export function containsOnlyDigits(input: string): boolean {
* @returns The unquoted string if it was quoted, otherwise the original string. * @returns The unquoted string if it was quoted, otherwise the original string.
*/ */
export function unquoteIfQuoted(value: string, quoteCharacter: string): string { export function unquoteIfQuoted(value: string, quoteCharacter: string): string {
if (value.startsWith(quoteCharacter) && value.endsWith(quoteCharacter)) { if (
quoteCharacter &&
value.startsWith(quoteCharacter) &&
value.endsWith(quoteCharacter)
) {
return value.slice(1, -1); // Remove first and last character return value.slice(1, -1); // Remove first and last character
} }
return value; return value;