Skip to content

Commit

Permalink
variable name changes
Browse files Browse the repository at this point in the history
Signed-off-by: Efe Barlas <ebarlas@purdue.edu>
  • Loading branch information
efebarlas committed Jul 9, 2021
1 parent 8f7ca34 commit 1470c23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/core.ts
Expand Up @@ -98,7 +98,7 @@ export interface CurrentOptions {
verbose?: boolean
discriminator?: boolean
unicodeRegExp?: boolean
useRe2?: boolean
useRE2?: boolean
timestamp?: "string" | "date" // JTD only
parseDate?: boolean // JTD only
allowDate?: boolean // JTD only
Expand Down Expand Up @@ -221,7 +221,7 @@ type RequiredInstanceOptions = {
| "validateFormats"
| "int32range"
| "unicodeRegExp"
| "useRe2"]: NonNullable<Options[K]>
| "useRE2"]: NonNullable<Options[K]>
} & {code: InstanceCodeOptions}

export type InstanceOptions = Options & RequiredInstanceOptions
Expand Down Expand Up @@ -250,7 +250,7 @@ function requiredOptions(o: Options): RequiredInstanceOptions {
validateSchema: o.validateSchema ?? true,
validateFormats: o.validateFormats ?? true,
unicodeRegExp: o.unicodeRegExp ?? true,
useRe2: o.useRe2 ?? false,
useRE2: o.useRE2 ?? false,
int32range: o.int32range ?? true,
}
}
Expand Down
10 changes: 5 additions & 5 deletions lib/vocabularies/code.ts
Expand Up @@ -6,7 +6,7 @@ import {alwaysValidSchema, Type} from "../compile/util"
import N from "../compile/names"
import {useFunc} from "../compile/util"
import re2 from "../runtime/re2"
import * as Re2 from "re2"
import * as RE2 from "re2"
export function checkReportMissingProp(cxt: KeywordCxt, prop: string): void {
const {gen, data, it} = cxt
gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
Expand Down Expand Up @@ -94,18 +94,18 @@ export function callValidateCode(

export function usePattern({gen, it: {self, opts}}: KeywordCxt, pattern: string): Name {
const u = opts.unicodeRegExp ? "u" : ""
const useRe2 = opts.useRe2
if (u === "u" && useRe2) {
const {useRE2} = opts
if (u === "u" && useRE2) {
try {
const engine = new Re2(pattern)
const engine = new RE2(pattern)
return gen.scopeValue("pattern", {
key: pattern,
ref: engine,
code: _`new ${useFunc(gen, re2)}(${pattern})`,
})
} catch (e) {
self.logger.log(
"Warning: Fallback to default regex engine. Please verify the safeness of your regex"
"Warning: One of the regexes in the schema is not supported by RE2. Falling back to the native regex engine"
)
}
}
Expand Down

0 comments on commit 1470c23

Please sign in to comment.