@metreeca/qest - v0.12.0
    Preparing search index...

    Function decodeCriteria

    • Decodes criteria from a URL-safe string.

      Parses an application/x-www-form-urlencoded string into a Criteria, recursively resolving internal IRIs against the provided base. The decoded criteria are validated and deeply frozen unless lenient is true.

      Note

      The decoder accepts both canonical and shorthand forms:

      • Prefix operators (canonical): >=price=100
      • Postfix operators (shorthand): price>=100
      • Double-quoted strings (canonical): name="widget"
      • Unquoted strings (shorthand): name=widget
      • A string value may carry a single postfix @tag suffix, lifting it into a one-entry Dictionary

      Keyed values are always reconstructed in the multi-valued form, since Options are inherently multi-valued and scalar/array forms are indistinguishable in form encoding.

      Warning

      The codec treats the @tag suffix as an opaque key and assigns it no semantic meaning. Consumers are responsible for interpreting the resulting Dictionary using schema-based information.

      Parameters

      • encoded: string

        The form-encoded Criteria string

      • options: DecoderOpts = {}

        Decoding options

        Configuration options for decoding operations.

        • Optional Readonlybase?: IRI

          Base IRI for IRI resolution (must be absolute and hierarchical).

          Resolves internal IRIs to absolute form.

          If omitted, IRIs are resolved against the app namespace IRI (app:/#).

        • Optional Readonlylenient?: boolean

          Disables structural validation after decoding.

          Allows the caller to handle validation independently using more advanced or specialised tools, for example for improved error reporting.

          • When true, structural checks are skipped and only syntax errors are reported through exceptions
          • When false, both syntax and structural errors are reported through exceptions

          If omitted, decoders apply internal structural validators to the input.

      Returns Criteria

      The decoded deeply immutable criteria with resolved IRIs

      TypeError If base is not a hierarchical IRI

      Error If encoded is malformed or unparseable

      decodeCriteria("~name=widget&price>=50&^price=1&#=25");
      // → { "~name": "widget", ">=price": 50, "^price": 1, "#": 25 }