Reference / @open-music-sdk/core / segmentOf
Function: segmentOf()
function segmentOf(
fn,
name,
value
): string;Defined in: packages/core/src/check.ts:129
value as one segment of a path, percent-encoded. A question mark, a hash or a space is encoded and stays in the segment. What could be read as leaving it is refused: a slash, a backslash, a percent sign and a control character, and "." and "..", which a URL parser reads as "here" and "one up". So a value from outside cannot turn a request for one endpoint into a request for another, where a different token may be sent.
Parameters
fn
string
The name of the function the value was handed to, for the error.
name
string
What the function calls this argument, for the error, such as "id".
value
unknown
What the caller gave.
Returns
string
value percent-encoded, as encodeURIComponent encodes it.
Throws
TypeError if value is not a string of 1 to 64 characters, holds a slash, a backslash, a percent sign, a control character or half of a surrogate pair, or is "." or "..".