diff --git a/src/renderer/utils/jsonPath.ts b/src/renderer/utils/jsonPath.ts index 3aedbd0919..a4ea5db3ae 100644 --- a/src/renderer/utils/jsonPath.ts +++ b/src/renderer/utils/jsonPath.ts @@ -4,12 +4,13 @@ */ import { JSONPath } from "@astronautlabs/jsonpath"; +import { TypedRegEx } from "typed-regex"; const slashDashSearch = /[\\-]/g; const pathByBareDots = /(?<=\w)\./; const textBeforeFirstSquare = /^.*(?=\[)/g; const backSlash = /\\/g; -const kubectlOptionPrefix = /^\$?\.?(?.*)/; +const kubectlOptionPrefix = TypedRegEx("^\\$?\\.?(?.*)"); const sliceVersion = /\[]/g; const tripleDotName = /\.\.\.(?.)/g; const trailingDotDot = /\.\.$/; @@ -28,10 +29,10 @@ const trailingDotDot = /\.\.$/; * - Allow `...foo` as well as `..foo` */ export function convertKubectlJsonPathToNodeJsonPath(jsonPath: string) { - const startMatch = jsonPath.match(kubectlOptionPrefix); + const startMatch = kubectlOptionPrefix.match(jsonPath); let start = "$"; - if (!startMatch) { + if (!startMatch.groups) { return start; }