File size: 1,698 Bytes
2517be1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | /**
* URI Template constants for RFC 6570 template processing.
*/
/** URI scheme separator */
export const URI_SCHEME_SEPARATOR = '://';
/** Regex to match template expressions like {var}, {+var}, {#var}, {/var} */
export const TEMPLATE_EXPRESSION_REGEX = /\{([+#./;?&]?)([^}]+)\}/g;
/** RFC 6570 URI template operators */
export const URI_TEMPLATE_OPERATORS = {
/** Simple string expansion (default) */
SIMPLE: '',
/** Reserved expansion */
RESERVED: '+',
/** Fragment expansion */
FRAGMENT: '#',
/** Path segment expansion */
PATH_SEGMENT: '/',
/** Label expansion */
LABEL: '.',
/** Path-style parameters */
PATH_PARAM: ';',
/** Form-style query */
FORM_QUERY: '?',
/** Form-style query continuation */
FORM_CONTINUATION: '&'
} as const;
/** URI template separators used in expansion */
export const URI_TEMPLATE_SEPARATORS = {
/** Comma separator for list expansion */
COMMA: ',',
/** Slash separator for path segments */
SLASH: '/',
/** Period separator for label expansion */
PERIOD: '.',
/** Semicolon separator for path parameters */
SEMICOLON: ';',
/** Question mark prefix for query string */
QUERY_PREFIX: '?',
/** Ampersand prefix for query continuation */
QUERY_CONTINUATION: '&'
} as const;
/** Maximum number of leading slashes to strip during URI normalization */
export const MAX_LEADING_SLASHES_TO_STRIP = 3;
/** Regex to strip explode modifier (*) from variable names */
export const VARIABLE_EXPLODE_MODIFIER_REGEX = /[*]$/;
/** Regex to strip prefix modifier (:N) from variable names */
export const VARIABLE_PREFIX_MODIFIER_REGEX = /:[\d]+$/;
/** Regex to strip one or more leading slashes */
export const LEADING_SLASHES_REGEX = /^\/+/;
|