UAInspector v0.15.1 UAInspector.Util View Source
Utility methods.
Link to this section Summary
Functions
Upgrades a database regex into a detection regex
Replaces an empty string with :unknown
Sanitizes a model string
Sanitizes a name string
Sanitizes a version string
Converts an unknown version string to a semver-comparable format
Replaces PHP-Style regex captures with their values
Link to this section Functions
Upgrades a database regex into a detection regex.
This prevents matching a string with other characters before the matching part.
Replaces an empty string with :unknown
.
Sanitizes a model string.
Sanitizes a name string.
Sanitizes a version string.
Converts an unknown version string to a semver-comparable format.
Everything except the major
and minor
version is dropped as
these two parts are the only available/needed.
Missing values are filled with zeroes while empty strings are ignored.
If a non-integer value is found it is ignored and every part including and after it will be a zero.
Examples
iex> to_semver("15")
"15.0.0"
iex> to_semver("3.6")
"3.6.0"
iex> to_semver("8.8.8")
"8.8.0"
iex> to_semver("")
""
iex> to_semver("invalid")
"0.0.0"
iex> to_semver("3.help")
"3.0.0"
iex> to_semver("0.1.invalid")
"0.1.0"
Replaces PHP-Style regex captures with their values.