mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-11-07 01:14:57 +05:30
fix: edge case in unquote function (when null)
This commit is contained in:
parent
b96c12bbd2
commit
f6fd1d9a04
1 changed files with 5 additions and 1 deletions
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue