mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-19 05:59:34 +02:00
fix: edge case in unquote function (when null)
This commit is contained in:
@@ -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;
|
||||||
|
Reference in New Issue
Block a user