Skip to content

Taxum / @taxum/core / http / parseQValue

Function: parseQValue()

parseQValue(value): null | number

Defined in: http/content-encoding.ts:149

Parses a Q-value string from an input and returns its numerical representation.

The Q-value string is a weight factor used in HTTP headers, typically in the format "q=value", where the value is a floating-point number between 0 and 1 inclusive with up to three decimal places.

The returned value is multiplied by 1000 to ensure it's an integer between 0 and 1000 inclusive. If the input is invalid or the Q-value is not within the valid range, null is returned.

Parameters

value

string

Returns

null | number