misc: add support for number matching in oidc and jwt

This commit is contained in:
Sheen Capadngan
2025-08-23 11:38:03 +08:00
parent 461deef0d5
commit 817daecc6c
4 changed files with 22 additions and 15 deletions
+4 -4
View File
@@ -1,11 +1,11 @@
/**
* Safely retrieves a value from a nested object using dot notation path
*/
export const getStringValueByDot = (
export const getValueByDot = (
obj: Record<string, unknown> | null | undefined,
path: string,
defaultValue?: string
): string | undefined => {
defaultValue?: string | number | boolean
): string | number | boolean | undefined => {
// Handle null or undefined input
if (!obj) {
return defaultValue;
@@ -26,7 +26,7 @@ export const getStringValueByDot = (
current = (current as Record<string, unknown>)[part];
}
if (typeof current !== "string") {
if (typeof current !== "string" && typeof current !== "number" && typeof current !== "boolean") {
return defaultValue;
}