encodeSegment

tagtree · /core·function

Encodes a single cache-key segment so it is safe to join with . as a separator; escapes . and : in addition to the characters encodeURIComponent already handles.

Signature

@nordcom/commerce-tagtree
function encodeSegment(value: string | number): string;

Parameters

NameTypeDescription
valuestring | number

Returns

The percent-encoded segment string, safe for use as a dotted-path component.

Example

encodeSegment('shop.example.com'); // 'shop%2Eexample%2Ecom'
encodeSegment(42);                 // '42'

ContractTestOptions runAdapterContract AdapterCtx CacheAdapter CacheInstance CacheKey CacheSchema CacheSchemaShape

Sourceencode.ts:17Edit the JSDoc directly

On this page