mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-12-17 17:56:38 +00:00
utils: moving unquote function to utlis (string)
This commit is contained in:
parent
863f7d05fa
commit
3d243665f3
@ -46,3 +46,16 @@ export function reverseString(input: string): string {
|
|||||||
export function containsOnlyDigits(input: string): boolean {
|
export function containsOnlyDigits(input: string): boolean {
|
||||||
return /^\d+(\.\d+)?$/.test(input.trim());
|
return /^\d+(\.\d+)?$/.test(input.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* unquote a string if properly quoted.
|
||||||
|
* @param value - The string to unquote.
|
||||||
|
* @param quoteCharacter - The character used for quoting (e.g., '"', "'").
|
||||||
|
* @returns The unquoted string if it was quoted, otherwise the original string.
|
||||||
|
*/
|
||||||
|
export function unquoteIfQuoted(value: string, quoteCharacter: string): string {
|
||||||
|
if (value.startsWith(quoteCharacter) && value.endsWith(quoteCharacter)) {
|
||||||
|
return value.slice(1, -1); // Remove first and last character
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user