Hyperlinkv0.8.0-beta.28

SchemaTransformation

SchemaTransformation.stringFromUriComponentconsteffect/SchemaTransformation.ts:1582
Transformation<string, string, never, never>

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)
)
export const stringFromUriComponent: Transformation<string, string> = new Transformation(
  SchemaGetter.decodeUriComponent(),
  SchemaGetter.encodeUriComponent()
)
Referenced by 1 symbols