UNPKG

@progress/sitefinity-nextjs-sdk

Version:

Provides OOB widgets developed using the Next.js framework, which includes an abstraction layer for Sitefinity communication. Additionally, it offers an expanded API, typings, and tools for further development and integration.

25 lines (24 loc) 675 B
export class ValueParser { inputType; parser; escape; escapeRegEx; constructor(inputType, parser, escape, escapeRegEx) { this.inputType = inputType; this.parser = parser; this.escape = escape || false; this.escapeRegEx = escapeRegEx ? escapeRegEx : /[\-\[\]{}()*+?.,\\\^$|#\s]/g; } canParse(inputType) { return this.inputType === inputType; } ; parse(value) { let parsedValue = this.parser(value); if (this.escape === true && typeof parsedValue === 'string') { return parsedValue.replace(this.escapeRegEx, '\\$&'); } return parsedValue; } ; }