effect-io-ai

Package: effect
Module: SchemaTransformation

SchemaTransformation.stringFromUriComponent

Decodes a URI component encoded string into a UTF-8 string and encodes a UTF-8 string into a URI component encoded string.

When to use

Use when you need a schema transformation to store structured data in URL query parameters or fragments, such as composing with Schema.parseJson to round-trip JSON through a URL.

Details

Decoding calls decodeURIComponent and fails if the input contains malformed percent-encoding sequences. Encoding calls encodeURIComponent.

Example (Defining a URI component schema)

import { Schema, SchemaTransformation } from "effect"

const schema = Schema.String.pipe(
  Schema.decodeTo(Schema.String, SchemaTransformation.stringFromUriComponent)
)

See

Signature

declare const stringFromUriComponent: Transformation<string, string, never, never>

Source

Since v4.0.0