Files
llama.cpp/tools/ui/src/lib/constants/uri-template.ts
T
stduhpfandGitHub 3a479c9132 ui: Add max image size option (#22849)
* webui: Add max image size option

* remove magic numbers

* support all image formats

* use const

* Move regex to match b64 images to constants

* use SETTINGS_KEYS to get max image resolution setting

* Do not touch the image if already under the size threshold
2026-05-21 00:00:09 +02:00

61 lines
1.8 KiB
TypeScript

/**
* 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 = /^\/+/;
/** Regex to match base64-encoded image URIs (format: "data:image/[media type];base64,[data]")*/
export const BASE64_IMAGE_URI_REGEX = /^data:(image\/[a-z0-9.\-+]+);base64/;